The Catholic Church recognizes baptisms that fulfil four requirements: the use of the proper baptismal formula, the use of water, triple immersion or pouring, and an intention to perform a baptism as the Church understands it. The beliefs of the baptizer are actually irrelevant-a baptism by an atheist who doesn't believe in God or that baptism is in any way efficacious is nonetheless valid IF they understand and all involved intend to perform a Christian baptism (as the Catholic Church understands it). A strict understanding of the full depth and nature of Christian baptism is not necessary-otherwise I'd expect most baptisms would be invalid, as it is a very deep mystery!-only the intent to do what the Church does in baptizing.
The relevant section of the Catechism of the Catholic Church is 1256, Who Can Baptize:
1256 The ordinary ministers of Baptism are the bishop and priest and, in the Latin Church, also the deacon. In case of necessity, any person, even someone not baptized, can baptize, if he has the required intention. [T]he intention required is to will to do what the Church does when she baptizes, and to apply the Trinitarian baptismal formula. [T]he Church finds the reason for this possibility in the universal saving will of God and the necessity of Baptism for salvation.
In the comments, Ken Graham has brought up a document on a similar case, where the Congregation for the Doctrine of the Faith has determined that Mormon baptism is not valid. It is worth reading to see the logic of the Church as it relates to a possibly analogous case. The link is here: https://www.vatican.va/roman_curia/congregations/cfaith/documents/rc_con_cfaith_doc_20010605_battesimo_mormoni-ladaria_en.html
It is worth nothing that despite being hosted on the Vatican's website the document originated as an article in L'Osservatore Romano, rather than being an absolutely official document of the Church. However, I would still expect it to accurately report on the official decision of the Congregation for the Doctrine of the Faith, which is about as official as you can get.
Some sections are particularly worth bringing out in the context of this question:
Doctrinal errors usually do not invalidate baptism… [E]rrors of a doctrinal nature have never been considered sufficient to question the validity of the sacrament of Baptism. In fact, already in the middle of the third century Pope Stephen I, opposing the decisions of an African synod in 256 A.D., reaffirmed that the ancient practice of the imposition of hands as a sign of repentance should be maintained, but not the rebaptism of a heretic who enters the Catholic Church… The validity of the sacrament depends neither on the personal sanctity of the minister nor on his belonging to the Church.
The heretics considered by Pope Stephen I were the Donatists, who though separated from the Catholic Church did not definitively hold unorthodox views towards the Trinity (or at least, as those doctrines weren't defined until later they weren't condemned for such beliefs). However, as the whole point of THAT struggle was over the validity of sacraments performed by those who separated themselves from the Catholic Church it is interesting that I am unaware of any similar struggle over the Christological and anti-Trinitarian heresies from roughly the same era. I've asked a question about that here: Was there any controversy over the validity of sacraments during the Arian Controversy?
Right intention is the intention to do what the Church wants, what Christ wants (...) Even non-Catholics can validly administer Baptism. In every case, however, it is the Baptism of the Catholic Church, which does not belong to those who separate themselves from her but to the Church from which they have separated themselves. This validity is possible because Christ is the true minister of the sacrament: Christ is the one who truly baptizes
As above, the Catholic Church holds that Christ is the minister of Baptism, and is able to make up any defects of the minister, including those of doctrine.
Precisely because of the necessity of Baptism for salvation the Catholic Church has had the tendency of broadly recognizing this right intention in the conferring of this sacrament, even in the case of a false understanding of Trinitarian faith, as for example in the case of the Arians.
(Emphasis mine) Regardless of whether there was controversy at the time, it appears that the resolution was to consider the (anti-Trinitarian) Arians to be validly able to baptize, at least in the understanding of this author.
The article goes on to note that until this response in 2001, the presumption had been that Mormon baptism was a valid Christian baptism, due at least in part to the sheer number of new religious movements and the difficulty in investigation or communication by the relevant authorities and earlier precedents, especially the case of the "Hidden Christians" of Japan (who were ruled to have been validly baptized).
Huge divergence on Trinity and baptism invalidates the intention of the Mormon minister of baptism and of the one to be baptized
The Form (…) The formula used by the Mormons might seem at first sight to be a Trinitarian formula. The text states: "Being commissioned by Jesus Christ, I baptize you in the name of the Father, and of the Son, and of the Holy Spirit". The similarities with the formula used by the Catholic Church are at first sight obvious, but in reality they are only apparent. There is not in fact a fundamental doctrinal agreement. There is not a true invocation of the Trinity because the Father, the Son and the Holy Spirit, according to the Church of Jesus Christ of Latter-day Saints, are not the three persons in which subsists the one Godhead, but three gods who form one divinity. One is different from the other, even though they exist in perfect harmony. The very word divinity has only a functional, not a substantial content, because the divinity originates when the three gods decided to unite and form the divinity to bring about human salvation. This divinity and man share the same nature and they are substantially equal. God the Father is an exalted man, native of another planet, who has acquired his divine status through a death similar to that of human beings, the necessary way to divinization. God the Father has relatives and this is explained by the doctrine of infinite regression of the gods who initially were mortal. God the Father has a wife, the Heavenly Mother, with whom he shares the responsibility of creation. They procreate sons in the spiritual world. Their firstborn is Jesus Christ, equal to all men, who has acquired his divinity in a pre-mortal existence. Even the Holy Spirit is the son of heavenly parents. The Son and the Holy Spirit were procreated after the beginning of the creation of the world known to us. Four gods are directly responsible for the universe, three of whom have established a covenant and thus form the divinity.
As is easily seen, to the similarity of titles there does not correspond in any way a doctrinal content which can lead to the Christian doctrine of the Trinity. The words Father, Son and Holy Spirit, have for the Mormons a meaning totally different from the Christian meaning. The differences are so great that one cannot even consider that this doctrine is a heresy which emerged out of a false understanding of the Christian doctrine.
Basically, the Catholic Church doesn't see the Church of Latter-day Saints as a heretical, non-Trinitarian religious group. It sees them as not being even Christian, due to the dramatic difference in doctrine concerning what god[s] exist, what it means to be a god and the like. As a valid Christian baptism must at least be Christian, the conclusion is that Mormon baptism is not valid.
Two other points are brought up in relation to the doctrine of baptism itself:
A) According to the Catholic Church, Baptism cancels not only personal sins but also original sin, and therefore even infants are baptized for the remission of sins. This remission of original sin is not accepted by the Church of Jesus Christ of Latter-day Saints, which denies the existence of this sin and therefore baptizes only persons who have the use of reason and are at least eight years old, excluding the mentally handicapped. In fact, the practice of the Catholic Church in conferring Baptism on infants is one of the main reasons for which the Mormons say that the Catholic Church apostatized in the first centuries, so that the sacraments celebrated by it are all invalid.
To me, at first glance this might imply a sufficiently different understanding of what baptism is as to bring into doubt whether the intention is to "do what the Church does when she baptizes". However, numerous Protestant sects deny original sin, and I am unaware of any controversy over whether Lutheran or (Ana)Baptist baptism is valid for the Catholic Church.
B) If a believer baptized in the Church of Jesus Christ of Latter-day Saints, after renouncing his or her faith or having been excommunicated, wants to return, he or she must be rebaptized (cf. AF, pp. 129-131).
Even in regard to these last elements it is clear that the Baptism of Mormons cannot be considered valid; since it is not Christian Baptism, the minister cannot have the intention of doing what the Catholic does.
As above, to my understanding at least some Protestant sects hold similar views without their baptism being considered invalid by the Catholic Church. Hence, IMHO while these elements may cause doubts about the validity of Mormon baptism, in themselves they are not sufficient to rule one way or another.
Hopefully that is at least somewhat illuminating from the Catholic side. On the Biblical Unitarian side, I must confess a great deal of ignorance as to precisely who you're talking about. Unlike the Catholic Church or the Mormans, Biblical Unitarianism appears to be a blanket term applied to a number of groups, many of which are themselves relatively loosely connected without a central hierarchy to define doctrine. From what I can tell, the defining belief here is that the Son and the Father are separate beings, and that the Son was created by the Father and is lesser to Him. Wikipedia at least includes Arians as Unitarians, and as above Arians were considered to validly baptize by the Catholic Church. Other Unitarians appear to outright deny the divinity of the Son and claim that Jesus of Nazereth was purely human; I'm unsure as to whether or why they would baptize "in the name of the Father and the Son and the Holy Spirit", but (IMHO) that would throw much greater doubt on the validity of their baptisms
- A blanket "non-Trinitarian = invalid baptism" is contrary to the teachings of the Catholic Church, as the Arian baptism was considered valid despite claiming Christ was a creation of the Father.
- In at least one case, a sufficiently alien understanding of who God is is sufficient to make the baptism invalid, despite observing a similar form (possibly in conjunction with other significant doctrinal irregularities).
- This case itself was considered new and exceptional in the history of the Catholic Church. As such, it should probably be read as narrowly applying to the Church of Christ of Latter-day Saints rather than broadly as applying to any group that holds any similar beliefs.
- However, it cannot be held definitively that another group with grossly incompatible beliefs nevertheless baptizes validly either-the Church initially presumed Mormon baptism to be valid and continued to do so for over 150 years, only to determine that it was not when it looked into matters more closely.
Without further information on the baptizer or baptism, or an official investigation by the relevant authorities, it is difficult to say definitively whether the baptism would be valid or not. Hence, my answer of "possibly"