There have been certain times when we have not been able to find healthy food on a consistent basis. Unhealthy options, whether at home or a gathering, sneak in our routine in any case. I know it sounds very simple but the solution I apply works well for me.
We should keep in mind that a human body is very efficient and after the growth years, it does not require a lot of energy to operate. In general, an adult requires 2000 to 2500 calories per day in a normal routine. So when the food is unhealthy, I try to eat as little as I possibly can. For example, two slices of pizza are more than enough and the third is not actually required. Half a burger would not let you feel hungry and the remaining can go in the dust bin. If I am cutting the cake, a smaller piece will suffice. The less I eat, the less unhealthy stuff goes inside my body and hence the damage it can do to my biological systems is restricted to only a certain extent. If I feel hungry even before the start, I can drink a large glass of water beforehand.
In conclusion, in a situation where you cannot choose which meal to eat, be prepared to eat relatively more when you find healthy food and eat less when all you have available is the junk food.