Elon Musk’s crusade to slash US government spending suffered setbacks on Thursday after a federal judge barred the Treasury department from handing data from its payments system to outsiders and one of the billionaire’s staffers was forced to resign over racist social media posts.