Yes, you can take medication while fasting. However, it's essential to consult with your doctor or pharmacist to ensure that the medication won't interfere with your fasting goals or cause any adverse effects.