There are many ways to do this, and for just as many reasons why this can make perfect sense. Let's start with popular means, and look at the reasons this makes sense.
Disclaimer: I don't know enough about the story you are working on to offer advice catered to it (otherwise your question is apt to be closed as too 'in-story'). So I offer some general suggestions that could offer the angle you desire, and you may tweak it until it fits.
Fight Club, in which a man finds out he's both protagonist and antagonist. He has Multiple Personalities (Dissociative Personality Disorder) one of which is the protagonist, the other is the antagonist. Yes, it's very dependent on psychology, but it's quite effective as used here.
Bane and Shadow, by Jon Skovron. In which one of the protagonists is 'magically altered', and brainwashed, to be controlled by the antagonists to do their dirty work. He doesn't realise he's the bad guy while under their influence, and has no memory of his deeds while under their power. While this also has a very psychological undertone, it's done quite well in my opinion.
Now. What I suggest, if you do not wish to take a more psychological approach (though, it does offer exactly what you want), there are options.
First, you can consider either making simply putting the protagonist into very different situations. Fact is, we react differently to different situations. You can do this with time, literally having the two storylines play out a decade apart. A lot can happen in ten years, and we could become someone we barely recognise if the events leading up to that drastic change are significant.
You could also have this person be a 'spy' of some sort, needing to repress certain thoughts and aspects of their self in order to fly under the radar.
You can also have a genderfluid person, though I don't advise this, for the purpose of it being a bit misleading in its entirety. Meaning, it gives people an incorrect view of what genderfluid is (and while that isn't something I believe should be done, it is an option all the same).
Another rather interesting aspect, and one I've seen done really well, is with a transgender person. Using the same 'different timeline' suggestion as above, you can show them in one timeline as "pre-transition" and "post-transition", which would usually mean the world reacts differently to them because of the perceived difference (difference in appearance). This would allow for a certain amount of growth, and it could offer a solid reasoning why the same person reacts differently.