I always understood that the USA is built on a delicate balance of power between the federal and state governments. But here the federal government is sending thugs who, masked or unmasked, are brazenly killing people in bizzare circumstances. And the best the state can do is PTFO?
What makes you believe ICE is going to follow a judge's orders? They are already routinely violating it when it comes to deporting people.
Or, if you want to be even more pessimistic: what makes you believe the current Supreme Court is going to rule based on law, instead of based on political affiliation?
The USA's balance of power is horribly broken. To give just one simple example related to the previous: having the Supreme Court be nominated by the President and confirmed by a simple majority in the Senate? That's just asking for trouble. It'd be far better to have judges nominated by a politically-independent organisation (like the currently-sitting judges, or a national bar association) and confirmed by a two-thirds majority in the House/Senate (preventing anyone controversial, so you get boring, professional, and by-the-book judges - like they are supposed to be).
Of course they can, but the governor and mayor know that ordering the police to do this means they completely lose what little control they have over the police, since the police support ICE and will believe it to be their patriotic duty to refuse the order.