BEIJING—China’s Communist Party leadership delivered a sharp warning to Hong Kong’s pro-democracy camp, taking aim at any officials deemed to defy the central government’s authority in the semiautonomous city.

In effectively barring two would-be Hong Kong lawmakers from taking their seats because they had insulted China, top legislators in Beijing invoked a national-security provision in Hong Kong’s miniconstitution to warn any lawmaker, senior civil servant or judicial officer against flouting their oath of office, which...