Donald Trump has seized on the government shutdown as an opportunity to reshape the federal workforce and punish detractors.