Can you waive those protections away by signing a contract that contains a clause that forbids salary discussions, or would that clause of the contract become unenforceable?
It would be unenforceable, with the caveat that the protection only applies to non-supervisory roles and only when discussing salary with other employees internally. Companies can still limit your ability to disclose your salary externally, as a trade secret.