President Trump has threatened to shut down Twitter, regulate social media and expand the government’s power to oversee the Web, part of an all-out assault against Silicon Valley tech giants that he has long accused of trying to undermine his reelection.