I would think it depends on what medicine they give you. If you get antibiotics some can be taken on an empty stomach, some before food, some after food. Only one of those could be compatible with fasting depending on how often you need to take them.
Beyond that skipping one meal a day should not have that much of an impact on your immune system.
Fasting is a natural medicine. Most sick animals will naturally fast. Autophagy helps improve your immune system. However, fasting will also mess with medicine. If you are taking a prescription be sure to consult your physician.