If you'll pardon a man's view on this:
I've spent forty years working in and managing such workplaces. If you give a witty or "bantery" response, then you're playing on their turf, accepting their rules. It becomes an exercise in oneupsmanship. You're dealing with men who genuinely believe that the world belongs to them, that boys have the right to be boys and do boyish things, and that they don't need to moderate their behaviour to accommodate other people beyond what they see as common politeness. And yes, such people can still be good, supportive colleagues and friends. They're wrong, not bad people.
My uncle used to run the Miner's Welfare (a social club for miners) back in the 60s in Mansfield. He once told me a story of a group of miners who would stand there, pint in hand, making jokes. The trick was to cap the last person's joke with a better comment of your own. They became so good at it, and achieved such a level of virtuosity, that they eventually spent the whole evening in absolute silence. No one dared say anything for fear of getting slapped down. Wit of that type is about power and alpha maleness in the group. As a woman, you can't win. You might get a reputation as a "good sort", and respect for it in a "she's one of the lads" way, but you are still acknowledging the workplace as a male space by playing a male game.
The only way to deal with it is to refuse to play the game. Just say "no", and nothing else unless you are asked in a spirit of genuine enquiry. Say it pleasantly, kindly and with empathy, but with a tone of absolute finality. Then move on.
The problem is that the men should not see the workplace as a space which belongs to them, but to the company. And sorting that problem out is a management issue, not one for the workforce to sort out amongst themselves. Talk about it with the boss. Unless you are the boss, of course.