The ruling comes amid broader disputes over the Trump administration's efforts to shrink the federal workforce.