Even if you could hide it, which I don't think you can, then anyone could still find it by using the browser inspector, or they could work it out if they know how profile URLs work in XenForo (and user IDs can easily be found by other means anyway e.g via mentions).
Why do you want to hide them from some user groups anyway?
We use real names on our site. I had a custom addon made that hides their real name which than gets replaced by a custom field when your not signed in. My problem is when you hover over the username that is replaced by a custom field it still shows there real name. Which is why I would like to hide it or just plain get rid of it.