Pro-Beijing lawmakers fast-tracked the legislation, with tough punishment for acts considered “external interference,” insurrection and other offenses.