Thus far, no actual treaty has ever been invalidated; the closest is an executive agreement in Reid v. Covert: https://en.wikipedia.org/wiki/Reid_v._Covert
In other words, we can't force other countries to not all agree to raise tariffs on goods that they import from the US. The constitution doesn't matter, because they are foreign governments. Our laws have no bearing there.
If that wasn't the case then any country could use their laws to force people in other countries to do whatever. Certain activities would be both required and banned at the same time. Here in the US it's illegal to coerce a voter, and in Australia voting is mandatory. There's no way to reconcile those two laws.
Honestly, I would think it more likely that private contracts, particularly NDAs, would be used to prevent undercover investigations. You can (more or less) sign away your First Amendment rights, after all.
So, if I understand this properly, you're saying that the government can't make you sign away your first amendment rights, but they can order you not to speak ('disclose information') and then jail you?
Also, it's not really a counterexample, because you do not sign away your rights when you sign the enlistment papers, you loose some of your rights by simply being part of the military. People who where drafted back in the 60s also lost had their rights limited, even though they did not voluntarily sign any papers or agreed to anything.
Further, this is an act of the government, and not a civil contract. No CIVIL CONTRACT can take away ANY of your constitutional rights.
http://www.firstamendmentcenter.org/judge-nursing-student-wa...
Civilian law generally applies to active duty military personnel the same as to anyone else (though some laws have express exceptions or alternate provisions for military personnel), and the UCMJ even provides for the delivery of military personnel accused of violations of law by the civil authorities to be delivered to those authorities. [UCMJ Art. 14, 10 U.S.C. Sec. 814]
More to the point upthread, members of the military retain First Amendment rights, and military regulations have been struck down for violating the First Amendment.
Its not unheard of for senior officers' careers to be ended after a negative OIG report.