Ugh yes, sadly I have experienced this. For example my dad walked into my house one time (the DxE Philly activist house), which is full of signs and banners about animal rights. He wasn't here for 10 seconds before he started making jokes about the delicious burger he ate before coming over.
I, like you, kinda just froze in the moment and didn't say anything.... I was so shocked that he would disrespect me in my own house like that. What happened to the "my house, my rules" mantra I had drilled into my head as a kid? I just gave him a dirty look and changed the subject....
Next time I am prepared to say, "That's very disrespectful towards me and what I stand for and is especially inappropriate in my own home."
In your case, maybe just saying "That is very cruel and disrespectful. As your friend/family/coworker I would never disrespect your values that way so I'd appreciate the same courtesy." ?
I totally understand the freezing in the moment though.... You kinda just need to practice and mess up and practice some more, I guess