MORDINU dude! Some examples would help greatly, it depends if ya interested in the girl yourself or if he's just putting you down to attempt to show off. It's really not a great social tool unless the situation calls for it or ya look clueless. Guys that do this in a clueless way fuck themselves with it.
Top an bottom if you have to, tool them. They're trying to use you to build their status so knock them right back down. If you can ignore them, give them a look and they fall in line that's better but if they think they can take shots at you and have done so a few times you possibly don't have this power.
It's frame control ultimately, there's a few ways to do it by either rolling with it, being unfazed and flipping the script on them or just full out shooting back. Each situation will be handled differently.
Russell brand has some great frame control, there's articles online discussing it
Tool them by using the law of least effort and using non verbal behaviour. Of it doesn't work just openly mention what they are doing in a way that makes them awkward next to the girl. They will just keep misbehaving because you let them get away with it .