troop_set_type is what you're looking for, like for instance in the start game menu:
(troop_set_type,"trp_player", 0), #male
which basically makes him a man, with 1 being female while 2 and onwards are your new race types
added a camp menu option and from there went male to female and back again several times without any apparent complications
(troop_get_type, ":troop_type", "trp_player"),
(eq, ":troop_type", 1), #female
if case ya later need to check if your fella's a woman, for example
gonna check how it works with using triggers and dialogs as well just in case
Edit:
did a simple trigger that changed the player's troop type every 4 hours and it worked without a hitch
however when I told my companions to get their genders switched it didn't take effect until after the conversation had ended, which I guess isn't too bad, would be greedy to want them to switch right in front of ya