A legal filing from scores of U.S. technology companies opposing President Donald Trump’s immigration order draws a new line in the industry’s complicated relationship with the administration that is likely to have repercussions beyond the standoff in the courts.

In a matter of weeks, tech chief executives have gone from tentative efforts to work with Mr. Trump—despite acrimony during the presidential campaign—to taking a strong public stand on one of the signature policies of the first few weeks of his administration.

...