The judge accused the Trump administration of discriminating against minorities and L.G.B.T.Q. people and ordered the government to restore much of the funding.