A federal judge rebuked top Trump officials for public comments he said threatened the fairness of a criminal trial.