The halachah recognizes six or seven sexual identity categories: male, saris (2 types), androgynus, tumtum, aylonit, and female. This sheet gives the Rambam's succinct definitions of those categories; illustrates that the 'non-binary' categories weren't considered exotic or disastrous with midrashim associating them at Adam, Abraham, and Sarah, as well as a midrash giving what sounds like a 'trans' identity for Isaac. Finally, two halachot illustrate a rabbinic awareness that gender expression follows 'local custom,' i.e. is socially constructed. The rabbinic halachic and midrashic tradition wasn't liberal in the modern sense with regard to these issues, but it does provide in impetus for a Jewishly rooted mind-opening with regard to sex and gender. Thanks to others who have posted source sheets on these issues, particularly Abby Stein, whose translation I quote and whose sheet pointed me to some of the other texts.
Note that in the previous two paragraphs, in Hebrew, Rambam uses the masculine/neutral pronoun הוא. So if we always translated הוא when applied to people as "he," the last sentence would come out, "And if a female organ is found, he is a female." In the first two sections, I kept הוא as male in 2:6, and היא as female in 2:13-14, since, as we'll see, there's something undefined that leans toward maleness in the case of androgynus and toward female for aylonit. But "they" or "s/he" would have also been a legitimate choice, I think.
More on dressing and cutting hair below. Note that an aylonit can be married (is "married off" (to a man)) according to the Mishnah, but if the husband didn't realize she was (/they were) and aylonit, he doesn't have to pay the specified ketubbah amounts if they get divorced.
ספר רזין דאורייתא, בשם הרבי ר' מיכל מזלאטשוב
אולם הכוונה, דנודע אשר יצחק נולד בנשמת נוקבא, וכמו שכתב בעל אור החיים הק', ועל ידי העקדה היה לו נשמת דכר להשפיע..... רק זאת נודע סדר הגלגולים. ולפעמים נקבה תסובב גבר כי בסבת הגלגול נשמת נקבה תבוא בזכר, כאשר י'תרעם ה'גלגל ו'יתרעש ה'חוזר לבוא בגלגול שני ושלישי. ואם נקבה אשר תסובב בגבר, ...
Sefer Razin D'Oraita, Rabbi Yechiel Michael from Zloczow (1731-1786)
It is known that when Issac was born, he was born with the soul of a female, as it is written in Or Hachaim, and through the akeidah (binding of Issac) he got a male soul that can influence (meaning, can impregnate). ... But, this is known according to the Sod (Secret/Mysticism) of reincarnation - that at times, a female would be in a male body, because in the reasons of gilgal (reincarnation) the soul of a female would come to be in a male. ...
Translation by Abby Stein
Terms for Gender Diversity in Classical Jewish Texts by Rabbi Elliot Kukla
Zachar: This term is derived from the word for a pointy sword and refers to a phallus. It is usually translated as “male” in English.
Nekevah: This term is derived from the word for a crevice and probably refers to a vaginal opening. It is usually translated as “female” in English.
Androgynos: A person who has both “male” and “female” sexual characteristics. 149 references in Mishna and Talmud (1st-8th Centuries CE); 350 in classical midrash and Jewish law codes (2nd -16th Centuries CE).
Tumtum: A person whose sexual characteristics are indeterminate or obscured. 181 references in Mishna and Talmud; 335 in classical midrash and Jewish law codes.
Ay’lonit: A person who is identified as “female” at birth but develops “male” characteristics at puberty and is infertile. 80 references in Mishna and Talmud; 40 in classical midrash and Jewish law codes.
Saris: A person who is identified as “male” at birth but develops “female” characteristics as puberty and/or is lacking a penis. A saris can be “naturally” a saris (saris hamah), or become one through human intervention (saris adam). 156 references in mishna and Talmud; 379 in classical midrash and Jewish law codes.