Don't worry about HR. They will back down the moment you CC them in an email (from your personal email address) to the legal department and ask legal if you should lawyer up in this case? Then you explain the case.
Play a little dumb, don't get personal (although one would be tempted if colleagues/management also get beyond professional), have plausible deniability ("I'm just asking if I need a lawyer for this. I don't know any of this!!?"), stay f*cking neutral in your wording of that email (don't give them any little emotional nook or cranny to grab their dirty fingers/tongue on).
Companies - especially bigger ones - have an hierarchy. Your boss? Also just has a boss! Who doesn't want 'trouble' from his/her employee (your boss, not you). A couple of times have I emailed a CEO (somewhere in another city in their HQ) of the company I worked for, because of this same sh1t. Never ever did this lead to trouble for me. Most of these times everything worked out, I stayed there, did my work, had nice social contacts with most of the crew, and the little b1tches from management/colleagues got nice and respectful or hated me in silence (I rather have them hate me in silence than mock me in the open). Other times it didn't feel right for me afterward, and then I left.
You don't do this for revenge, you do this for your own peace of mind. I sense you are not willing to brush your described situation off as just a little joking, which signals to me that it is about a flavor of disrespect in these interactions (which I understand is something you want to fix). The above solution lets them know - in a plausible deniable way (so you increase the chance of still having your job) - that you are able to f*ck harder with them and you can touch them where it hurts. The thing about this disrespect is that people are trying you, and if they sense they get away with it, it will come back at some moment, probably a little nastier even. And in the meantime you constantly don't feel good about it. It's better to nip it in the bud quickly.
I don't know where you're from, but where I'm from we have pretty good labor law and everybody in management knows that. If you signal that you also know (or that you're thinking of lawyering up, whether you actually do that or not), they think twice about messing with you.
Don't apply this advice as is. I'm not you, and you're not me. If you think you can deal with this by focusing on positive stuff and ignore the disrespect, by all means try that. I tried that sometimes, but it just didn't work for me. You might be different. I do know about people who honestly can deal with disrespect like that, while also sincerely staying positive about that workplace. I'm not one of them, I can't stay positive if that sh1t happens around me.