So long as the persons have not rendered themselves impotent, there is nothing preventing two transgender persons from marrying one another.
However, the Church essentially recognizes only the so-called biological sex of the persons. Hence, she would regard the transgender “man” as a woman, and the transgender “woman” as a man.
In general, the Church holds that the faithful have a strict right to the sacrament of matrimony, provided the candidates are one man and one woman, and there are no impediments (e.g., when at least one of the parties is already married to someone else, or impotent).
Hence, although transgenderism is deeply problematic (for the reasons I will mention below), that would not prevent a couple from marrying.
The background behind this
There is very little in Church documents regarding transexualism, because it is a relatively new phenomenon (at least, it did not become a major issue for the Church until very recently). It is not mentioned at all in Canon Law.
Pope Francis has spoken out against so-called gender theory (see, for example, the general audience on April 15, 2015), which asserts that a person’s sex (his biological configuration as male or female) is distinct from his gender (his subjective perception of being man or woman).
The problematic aspect of this theory is not so much that these two notions are distinct (they evidently are, because empirically, gender dysphoria does exist) but the idea that “biological” sex is malleable—that it can be changed by a mere external procedure (such as surgery or hormone treatment).
However, sound philosophical principles, backed up by good science, and reiterated in the Bible, can help to answer the question.
Man is one and whole
The first and most important principle is that a human being is one and whole. Man is not (as René Descartes famously asserted) a spirit that happens to be united to a body—as if the spirit and the body were separate beings. (See Descartes’ Meditations on First Philosophy, II, in which he explains res cogitans—i.e., the soul—and how it relates to res extensa—realites that are “extended” in space, including our body.)
Rather, each person is a unique and undivided being. His body is just as much a part of his being as his soul—so much so that it can only be separated from his soul with the greatest violence. (We call that “death.”)
Gaudium et spes, Vatican II’s pastoral constitution on the Church in the modern world, sums up this idea succinctly:
Though made of body and soul, man is one. … For this reason man is not allowed to despise his bodily life, rather he is obliged to regard his body as good and honorable since God has created it and will raise it up on the last day (Gaudium et spes, 14).
Indeed, a person’s bodily life is entirely imbued with and ennobled by his soul. It follows that even his biological functions—especially one as fundamental and profound as his sexuality—are most closely united to his soul.
Male and female he created them
A person’s “biological sex,” therefore, is given to a person from the moment of his conception, and it cannot be changed: it is far too fundamental a part of his being. Indeed, a person’s sex endures for all eternity. Although we can know this through reason alone, the Bible beautifully sums up this principle when it says,
So God created man [understood generically, as in “mankind”] in his own image,
in the image of God he created him;
male and female he created them (Genesis 1:27).
As the Catechism of the Catholic Church puts it,
Man and woman have been created, which is to say, willed by God: on the one hand, in perfect equality as human persons; on the other, in their respective beings as man and woman. “Being man” or “being woman” is a reality which is good and willed by God: man and woman possess an inalienable dignity which comes to them immediately from God their Creator (No. 369, emphasis added).
Consequently, the sex that a person is born with is the sex that he will possess for life (indeed, as mentioned, for all eternity). No amount of surgery or other treatment can change it. Catholics would encourage those experiencing gender dysphoria to seek professional help to manage or overcome it.
Regarding the marriage of transgender persons
For these reasons, the Church can only consider the sex that persons possessed from birth (in reality, from conception) when assessing whether a couple is able to marry. If one or both of the parties happens to be transgender, that is a secondary issue, so long as one man (male at birth) marries one woman (female at birth).