WASHINGTON—Some Supreme Court justices expressed sympathy for the so-called Dreamers even as they suggested during arguments Tuesday that the Trump administration was entitled to cancel the Obama-era program that protected nearly 700,000 illegal immigrants brought to the U.S. as children.

Reflecting the stakes, Tuesday’s argument was extended to 80 minutes from the usual hour. The administration has maintained since September 2017 that it had no choice but to cancel the DACA program after then-Attorney General Jeff Sessions...