If people are joking around with you, joke back.
Diffuse with humour
Example: "you're gay"
"okay but im on top"
Just laugh with it, its not always a struggle or testing, its just joking around a lot of the time. If its really that much trouble just laugh a little and shake your head to yourself as if to say "what a terrible joke" or "its funny only because its so bad". This sets a frame that the joke they made was low wit and because jokes are only funny if someone laughs they are less likely to make more jokes. Or even just think you're cool cos you can take a joke.
How about cutting them out of your social circle too, it doesnt have to be drastic but basically if someone doesnt live up to YOUR standards of what you accept as a friend then basically ignore them when they dont live up to your standards BUT MAKE sure to give good feedback when they are being nice. Dont inviite them out, dont invite them to switch to a new pub or wherever you go, make them feel left out of the group so they either:
a)stop putting up shit and join in and be nice.
b)hang around but feel left out and dont get to have fun.
c)They leave and you dont have them around anymore.
Another way is to simply tell them to cut it out. Just be casual about it like "dude, what are you doing, just chill out and have fun. No ones here to give each other shit.".
THE most important thing though is to remember the 2 most common solutions are;
just laughing it off either normally or with a slight 'disapproving' headshake, like he's embarrassing himself.
or
Cutting them out of your friendship, whether it be just you responding to them or the ENTIRE group. If you're good enough friends just say "hey guys, dont invite him out. he's a bit weird" or "i hate that kid, i literally hate him but invite him out anyway. its cool".
they'll respond "really? you okay with that?" so you respond with "well only if you really want him but i think we can have a better night. ive got some plans

" (note, if you wanna be the alpha then have some plans and ways to make a good night everytime)