Can polymorph and true polymorph alter a PC's race and sex? If a PC can be altered in such a way, can the PC speak and use his or her hands?
Well, for starters, polymorph can only turn things into beasts. Which is to say, creatures with the beast type - so no humanoids.
As for true polymorph, well...technically, by the rules, you can only use true polymorph to turn a creature into a creature with a Challenge Rating.
If you turn a creature into another kind of creature, the new form can be any kind you choose whose challenge rating is equal to or less than the target’s (or its level, if the target doesn’t have a challenge rating).
The target doesn't need a Challenge Rating, it can use its level - so it works on PCs. But the new form has to have a Challenge Rating, so you can't turn a PC into a PC, so to speak.
That means that, for example, turning your buddy the Human Fighter 20 into an Elf Fighter 20 isn't going to work. On the other hand, you could turn him into a Drow Elite Warrior (CR 5). So, changing a creature's race with true polymorph is possible, it's just not simple.
By the same token, you can't turn your buddy the Male Human Fighter 20 into a Female Human Fighter 20. However, (and this is why I picked drow), you could turn him into a Drow Priestess (CR 8). It's a little questionable whether this would actually change his gender, though.
The target’s game statistics, including mental ability scores, are replaced by the statistics of the new form. It retains its alignment and personality.
Again, going by the rules, true polymorph replaces the game statistics of a creature with those of another creature. But there's no clear evidence that gender is a game statistic. The Monster Manual has a very long section on Statistics, and gender isn't mentioned anywhere.
Any transformation along these lines will allow the use of hands and speech.
The creature is limited in the actions it can perform by the nature of its new form, and it can’t speak, cast spells, or take any other action that requires hands or speech, unless its new form is capable of such actions.
You may well have read all that and thought "That's stupid!" every step of the way. True polymorph is a 9th-level spell, up there with wish in terms of cosmos-altering power. It can turn a kraken into a crab, or a dragon into a dog.
That being the case, the easiest solution (as always) is to talk to your DM. If you say "Hey, can I use true polymorph to change race and/or gender?" then you'll get the answer that is true for your game.
Of course, if you are the DM, that doesn't help you all that much. If a player asks you this, and you're wondering what to say, well, it's up to you. I will warn you that allowing true polymorph to turn creatures into forms other than the ones with a CR and a statblock opens it up to some weird abuses and crazy shenanigans. So how you rule on this is up to you, but it might be worth having a think about how much you trust your players, and how okay you are with having this stuff in your game.
https://www.sageadvice.eu/2016/05/25/would-true-polymorph-allow-someone-to-change-their-race/ theres a sage advice on the subject. Seems like it may have just been a bit of a slip in wording to me.