Tl;dr - I think the title should be changed to "How can I react better if someone reveals an identity that I have little or no knowledge of?"
I prefer your title because of grammar and I care a lot about grammar. "confesses their identity that" is bad English. You don't 'confess' an 'identity', nor especially do you 'confess their identity that'.
You could argue that it's grammatical to 'confess to an identity', but that still feels off.
At best, the original title is awkwardly phrased and at worst it's flat-out ungrammatical.
'Confess' is semantically tied with action, and although it's fair to say that 'identifying as' or 'identifying with' are actions,
the noun 'identity' is not an action nor does it imply action the way that other nouns such as 'murder', 'adultery', 'ownership of' and 'preference for' do.
The most direct change would be to switch 'identity' to its verb:
How can I react better if someone confess to identifying with a group that I have little or no knowledge of?
Talking about the alternative you suggested... it seems okay but fails to match details found in the question body.
OP indicates that they are concerned not just with vegetarianism, but with religious affiliation, gender orientation, and refugee status.
Those just aren't personality traits (although I concede that not all of those are identities either.)
Therefore, I think both leave something to be desired... but I believe the core issue is that 'confess' is a sub-optimal word here.
Try 'reveal' instead - it works better with 'identity', doesn't imply (although it allows) that the identity/status was intentionally hidden or secret, and carries no negative connotation.
How can I react better if someone reveals an identity that I have little or no knowledge of?
It does make more sense to say 'confess' when taking into account that OP says that these identities are 'considered socially unacceptable or despised',
but... the full list (LGBT, Christianity, Islam, refugees, etc...) includes Christianity and Islam.
In any country where vegetarianism is strange, I would think that either Christianity or Islam would be socially accepted, meaning that this modifier is not universally applicable to the question's full breadth.