Donald Trump has barred Americans from investing in companies that US officials say are owned or controlled by the Chinese military.