I have a number of health issues related to food. Some are food allergies that I've had for decades. And 6 years ago, I developed something else unrelated that 22 doctors now haven't been able to diagnose. I'm mentioning it here so that you know the backstory before I give you my advice. But in real life, I'm so sick of telling people about it because there has been no diagnosis and so I have to explain all my symptoms and I just get depressed and frustrated telling my tale of woe.
Therefore, I'm very brief and very vague and that tends to be working pretty well.
If I don't want to eat something I just say "Oh, thanks. I have health issues and can't have that. Thanks anyway." That's usually vague enough that polite people won't press me further.
However, the condescending folks in your examples would probably ask "Oh, what issues?" to which I'd reply "It's a long story. I don't feel like getting into it right now." And then I bean dip. And if they asked again, I would just say "Really. In mixed company, no one wants to hear about my issues" and then walk away.
For people who already know about my health issues, I have heard the "Oh, that's so hard. That's so sad for you. How incredibly frustrating."
If I think they're sincere, I just say "Yes. Yes it is." And then don't continue. But if I think they're putting me down to feel better about themselves, I just say "Mmmm." As in "Yeah. I heard you. I acknowledge that you said something to me." But all I say is "Mmmm" and look bored at them. Because I've heard it all before. And they're looking for a reaction. So I just looked really bored. That usually stops them.