A federal judge has ordered the Trump administration to rehire thousands of probationary workers sacked in recent mass firings across multiple agencies.