No, the protected status is based on the actual use of the building, not whether the military use was agreed upon by the inhabitants.
See the Geneva Convention Article 12:
- Medical units shall be respected and protected at all times and shall not be the object of attack.
Notice that the protection is to the medical unit, not everyone inhabiting the same space as the medical unit.
- Under no circumstances shall medical units be used in an attempt to shield military objectives from attack. Whenever possible, the Parties to the conflict shall ensure that medical units are so sited that attacks against military objectives do not imperil their safety.
The first sentence means that whether the hospital agreed or not is irrelevant. The responsibility is on the warring party having territorial control of the hospital grounds. The second sentence means that situating a military activity within or under the hospital is in itself in a violation of the convention.
This section is specifically intended to prevent the "absurd" scenario you're describing.
Article 13 describes the protection stripping:
- The protection to which civilian medical units are entitled shall not cease unless they are used to commit, outside their humanitarian function, acts harmful to the enemy. Protection may, however, cease only after a warning has been given setting, whenever appropriate, a reasonable time-limit, and after such warning has remained unheeded.
So if a notice was given by the other warring party to remove non-medical activity from the building and it was not removed - the protection may be stripped. I don't know whether and how such notices were given in the specific case you're referring to. The "whenever appropriate" can carry a lot of weight here.