The injunction is a setback for Trump, who has sought to streamline the federal government through cuts and layoffs.