The construction firm Mears has banned its workers from having beards
"workers need to be clean-shaven in order to be safely fitted with a tight-fitting face mask when working in dusty environments, and exceptions are only made if a worker can’t shave or a mask cannot be worn for medical or religious reasons. But for the company to allow this either a medical certificate or a letter from a place of worship must be presented " Mears
You can not contract out of your legal obligations. It is a legal requirement for an employee to take steps to ensure their health and safety while at work.
It is also a legal requirement of employers to ensure the health and safety of those affected by the employer's work activity, be those persons employees or members of the public.
Neither party can contract out of their legal obligations any more than if a person hires you to kill them you can escape a murder charge by pointing out they asked you to do it.
The relationship between employer and employee is not one of equal power, the laws preventing someone signing away their legal rights and obligations are there for a reason.