I only need two premises.
1. The First Amendment applies to state laws.
This is based on establishment clause in the 14th amendment. Specifically the text: "No State shall make or enforce any law which shall abridge the privileges or immunities of citizens of the United States; nor shall any State deprive any person of life, liberty, or property, without due process of law; nor deny to any person within its jurisdiction the equal protection of the laws." The supreme court has ruled that this amendment extends the protections in the First Amendment to state laws.
2. State laws are used to enforce civil contracts.
You can look this up for your state if you don't believe me. In California where I live civil contracts are enforced by the
California Civil Code. This is a collection of laws that was passed by the state legislature.
The only logic I need to use that since the First Amendment applies to state laws and state laws are used to enforce contracts then a contract that violates the First Amendment cannot be enforced by the state.
This wouldn't automatically invalidate all NDA's because the Supreme Court has ruled that trade secrets are not protected by the First Amendment. It does mean that a person can't put any conditions they want into a contract and expect the government to help them enforce it.