This sentence can be considered funny or ironic based on the context in which it is being used, specifically because it starts with a very dramatic kind of assumption which can be a surprise. It can be humorous because there's a type of 'miscommunication' comedy arising from the abruptness of the topic - throwing it out into the conversation without any preamble. The humor or irony arises from the tension between what one expects to happen in a conversation and what actually occurs, considering it is an unusual, direct way to probe whether someone else knows about a personally significant revelation.
Secondly, the use of all capital letters, typically understood as 'shouting' in digital communication which, particularly in the online world, adds an extra layer of humor. All capital letters are typically used to show someone is yelling, or emphasize a point. But when used randomly or abruptly, it can often be funny because it is unexpected and appears quite dramatic, which can be seen as overreacting to the situation, hence amplifying the irony.
Thirdly, it can be ironic because the person who was supposed to be 'in the dark' about the speaker being trans, already knows, undermining the presumed secrecy. This is especially ironic if the speaker has been trying to hide it but finds out their efforts were fruitless, leading to a mix of possible embarrassment and relief.
The fourth reason is that the humor may stem from the double entendre in asking 'how did you know?' It could mean, "What gave me away?" playing into stereotypes around what being trans 'looks' like, which can be humorous if the respondent's logic is unfounded, outdated, or otherwise ridiculous.
Furthermore, if this is a statement by a character in a narrative, its ironic twist can be the disclosure of trans identity treated as a trivial yet shocking fact. The comedy or irony arises when the audience is aware of the character's trans status long before the character admits it, leading to laugh-at-you-not-with-you humor.
Lastly, the humor can arise from the speaker's surprise that someone knew about their trans identity. It seems to challenge the idea that being trans is something that can or should be hidden, offering a possibly sarcastic commentary on society's understanding and acceptance of trans identities. This reflects irony if the person being asked already exhibits an understanding, acceptance, or even advocacy for trans identities. HOW DID YOU KNOW I M TRANS