Yes, but your example doesn’t work here. The bedrock of what we call our free speech rights is more of a prohibition on Congress from passing laws that impede that. Signing such a contract doesn’t contradict the First Amendment.
It does though because its a contract. There are states which enforces, in their contracts, various anti-boycott measures regarding Israel. These are effectively anti-free-speech clauses and they are imposed by the government. But, are allowed because they are agreed to in the terms of the contract.