There isn't any framework where this would be seen as illegal or illegitimate.
Even under a foreign power's "national security interests", Hong Kong is pretty much an administrative convenience to asian markets than an outlier, as China knows how to run markets these days and has little qualms about capitalist functions, so it is very unlikely that major market disruptions would happen from even the most extreme scenarios imagined here. As such "rockets on Beijing" let alone any foreign diplomatic recognition of these internal issues would be very counterproductive.
In this case for whats productive, use this analogy: think of it more like a theorist in Ohio wondering if DC is causing a false flag attempt during a period of unrest in a US state or dependent territory. That theorist is never suggesting that a neighboring or powerful country intervene, while still being passionate about the idea that the unrest is being propelled in order to justify state control. Might be true, might not, doesn't matter, but still the only outlet to express discontent than suggesting a third party drop rockets on the capital!
Doing it just to effectively end "One China, two systems" would absolutely be breaking a teaty. Which is illegal.
The Sino-British Joint Declaration resulted in the enactment of the Basic Law, of which entitles China to provide for military support, intervention, and assumption of administrative functions in Hong Kong.
Its not breaking a treaty when you use the provisions of it.
The only stipulation of the treaty, an ideological line in spirit, is that the socialist policies are not enacted. All that means is that markets stay open and there are no strings attached when the state provides for you. That has nothing to do with the military entering.
And finally, articles 158 and 159 of the Basic Law put the "Standing Committee of the National People's Congress" as the final arbiter and interpreter of the whole thing. It has always been this way, and the rationale for not using it is thinner than ever.