Ruling deals blow to efforts by Donald Trump and Elon Musk to shrink government workforce