President Donald Trump threatened to veto an annual defense-policy bill if it doesn’t include language overturning a provision that gives social-media companies broad immunity for the content they publish from users on their sites.