A US appeals court has ruled most of Donald Trump’s tariffs illegal, setting up a potential Supreme Court battle that could upend his trade policy agenda.