A Manhattan federal judge on Thursday ordered the Trump administration to restore nearly $34 million in slashed funds to protect New York’s massive transit system from terrorism, saying the White House unlawfully tied the state’s grant to immigration policy.