First there's the question of whether sex or gender are binary, is there only men and women?
Least to say that is a simplification that ignores exceptions.
I don't think nearly all people can be defined male or female by personality. Which makes the original question to "can gender be opposite to sex" besides being in gray zone. But since there is a gray zone where someone can be argued to be of either gender (or between them), they are at least by some interpretation or definition people of gender opposite to their sex.
Then again, is there at all a definable mental gender? I identify as man, but also Caucasian and (ethnic) Finn, among other things. Are each of these physical biological qualities or social definitions?
Least to say they can be unclear. Around century and a half ago it took in US a court decision to define that Finns are white and NOT Asian.
It can be argued there's no inborn gender, certainly not definable to a binary choice.
Yet again, I think most of us would say that if our brain was put in a genderless robot, we'd continue to consider ourselves of the same sex/gender as before. In other words we do generally believe in having a mental gender, argument is more about how it forms, can it be different from sex and can and should it be changed. And indeed whether it is a more defining quality of a person than their physical sex.
I'm doing circles here and coming up with more questions than answers.