How is it any different from an NDA? You have a right to free speech, and a right to willingly enter a contract with another party which constrains that right. Presumably the drivers can break the contract. I’m not condoning F1’s actions here, in fact I think it’s pretty despicable, but it’s not clearly illegal for any obvious reason.