A divided panel of appeals court judges has ruled that a Trump administration policy illegally banned transgender troops from military service.