I try to think like the author in how to make a twist, so we have some elements:
Late introduced character who already know about their secret
Joins the protag team to make readers used to his presence
Gives him the "crossdresser gag" to make readers lower suspicions about the character
He...