President Donald Trump said he wouldn’t allow defense companies to issue dividends or buy back their own stock until they invest more in production and research, comments that triggered a selloff across the sector.