A US judge has dismissed a lawsuit by Elon Musk's X accusing a group of advertisers and major companies of illegally boycotting his platform.