dfhack console:
transform-unit -unit {ID} -race {race} -caste {caste} [-keepinventory][-duration forever|{ticks}]
I would suggest:
transform-unit -unit {ID} -race DWARF -caste FEMALE -keepinventory
for what your desiring, you can get the unit_id out gui/gm-manager or through teleport -showUnitId
the way you are doing it right now wont keep the change because his caste hasn't changed causing it to assume its been transformed, his transformation timer is at 0, so it immediately transforms him back to his original caste which is MALE.... it doesn't even care to check if the unit is a were creature or been transformed through some other game mechanic, just that he has a sign that he's been transformed and not matching his current caste.
this script basically just makes race/caste changes which causes it to transform into that race/caste... you can also add -duration {ticks} to give it a time limit, or at a latter date you can use -untransform in the line without the race or caste command to remove the transformation.... I was thinking of some interesting concepts with this, such as a rare material that when worn or equipped would transform the character into... who knows something insanely powerful... like a megabeast or a female! then when the item is dropped untransform them... or a rare race where all characters switch race every two years... interesting enough I had an issue with the use of transform-unit and guild system.... basically you could send pregnant dwarfs to go be transformed into men, who then would give birth as normal, but couldn't feed their babies....I also had children running around the fort who had a father who was female, or a mother who as male... talk about modern family and my two dads... 2 and 1/2 men?