薬を飲まなければなりませんか。
Do I need to take the medicine?
薬を飲まなくてもいいですか。
Can I not take the medicine?
If literally translated, that's what they mean. Essentially, they are both asking about the same thing, "Should this medication be taken?"
The first sentence is asking if taking the medication is necessary. The second question is asking if it's okay that you don't take the medication.