I had a company event not long after my surgery. I just told them I had food restrictions post operation. I didn't tell anyone what kind of surgery it was, but there were no questions and everyone was cool about it. It depends on how much they know, I guess. Everyone on my team knew I was out for surgery, though I never got into specifics. When asked, I just said gastrointestinal - a true statement, but also vague enough it could be anything as far as they knew, and that I had restrictions during the healing process. These were all pretty new colleagues and none were personal friends, so maybe they would have asked more questions if they were close friends.
Edited to add: You can always fake eating, if even saying the above is difficult. Put things on your plate, move them around. If there is anything you can eat, eat that and just play with the rest. Get a glass of wine and just never drink it.... that sort of thing.