This is an interesting question, and I don’t have any ‘official’ answer, but here are my thoughts:
John’s baptism was a baptism of repentance, which he distinguished from the baptism with the Holy Spirit and with fire that Jesus would bring. So his baptisms were valid, but not sacramental, just as a marriage may be valid without being sacramental. His baptism of Jesus would therefore be valid.
Another interesting thing to note is that even though John most likely did not baptize Jesus ‘In the name of the Father and of the Son and of the Holy Spirit", Jesus’ baptism was trinitarian. The Father was present when He said, “This is my beloved Son, with whom I am well pleased. Listen to Him.” (The actual text differs depending on translation, I unfortunately do not have a Bible available to me where I am right now.) The Son was obviously present. The Spirit was present in the form of a dove. So although Jesus may not have been baptized with a trinitarian formula, His baptism was a trinitarian baptism.