The question is therefore not legality in itself, but whether the (US) laws themselves are sensible and/or egalitarian. It's implied by the OP that they aren't (and I personally agree).
Here's the wording of the HK-specific law: "The Hong Kong Special Administrative Region shall enact laws on its own to prohibit any act of treason, secession, sedition, subversion against the Central People's Government, or theft of state secrets, to prohibit foreign political organisations or bodies from conducting political activities in the Region, and to prohibit political organisations or bodies of the Region from establishing ties with foreign political organisations or bodies."
Governments hold a monopoly on Force, not a monopoly on Truth.
It's different for people who do have a security clearance, because they signed away their First Amendment rights for classified information.
Also normal (non-government) NDAs let you sign away your right not to be punished for speaking about certain matters. I don't like it, but it's pretty well established.
Point is that—legally speaking—rights aren't actually inalienable.
Do you know the prominent cases of the examples you mentioned?
You can contract with another private entity to resolve disputes via arbitration, yes, but not with the state. The closest thing might be a plea agreement, but that happens after an indictment. You still have the right to a trial, but you may forego it if you choose.
I suppose if you're saying that a security clearance is like an NDA with the state, it's a reasonable comparison in function, but the means of prosecution is entirely different. It's like saying that everyone could be subject to UCMJ because of conscription.
So then this appears to be the difference between the Manning/Assange and Snowden/Greenwald cases: both Manning and Snowden held security clearances and violated them by sharing with Assange and Greenwald. But while Assange may have solicited and/or assisted Manning's crime, Greenwald just passively received the materials from Snowden's crime. So Greenwald is innocent and Assange is prosecuted.
Not sure if this would play the same in America.