If a couple marries in a Catholic Church in a state of mortal sin, is the marriage still valid or not?
Assuming that everything else is in order, namely, both of the couple are free to marry, they are baptized, they understand and accept the essentials of the sacrament and intend to live by them, they follow the proper form, etc etc., then – yes – such a marriage should be valid.
Validity of sacraments does not depend on the state of grace of the recipient.
Baptism and Confession and Anointing all can forgive the mortal sins of the one who receives them.
The Eucharist can be confected by a priest in the state of mortal sin, though if received… well… see St. Paul’s admonition to the Corinthians (cf. 1 Cor 11). But the state of soul of the recipient does not affect the validity of the Eucharist. It is a heresy of the highest order to suggest that Christ is not truly present in the Eucharist unless the recipient believes or is in the state of grace.
Confirmation, Holy Orders, Matrimony are validly received in the state of mortal sin.
That is to say, the sacrament is truly conferred. A man ordained in the state of mortal sin is truly ordained, the confirmand is confirmed, the member(s) of the couple, truly married. The state is conferred.
In the case of baptism, confirmation, priesthood, the ontological change to the person’s soul takes place, and they will forever be baptized, confirmed or ordained… even in the eternal punishments of Hell if they die in mortal sin. Matrimony ends with the death of one of the couple.
However, in all these cases (with the exception of baptism and, in a way, penance) the sacramental graces of the sacrament are not truly theirs until they return to the state of grace (the newly baptized is in the state of grace, as is the newly absolved, provided his confession was a good one, is absolved). Even though there is an ontological change with some sacraments, it is as if those sacraments slumber until they wake up and become effective in the person’s soul with the state of grace. We don’t know how God may give prevenient (forerunner) graces through those particular sacraments to help the person, inspire the sinner, to repent and seek absolution. Sacramental graces are actual graces. We receive them when we are in the state of grace. God in love and mercy gives another kind of actual grace which urges the sinner to repentance.
So, if someone in the state of sin gets married, he or she is truly married… they are married. But the advantages of sacramental graces which flow from the sacrament of matrimony will not be theirs until they are in the state of grace.
Think about the nobility, but difficulties, of the married state. The couple receives the gift of this vocation so that they can help each other to salvation. They can be tremendously helpful to each other. They can be horribly damaging to each other. Married people need all the supernatural helps they can get! It seems to me a first duty of a married person to love God more than the spouse and to seek always to be in the state of grace for both their sake.
If person marries in the state of sin, he or she should probably confess disrespect for the sacrament received, improperly approaching such an important moment which God offers to help the person to salvation. If the person married in the state of sin received Communion during the Nuptial Mass, he or she must confess that sacrilege as well.
That said, God is rich in mercy and love. His forgiveness is ours for the sincere asking.