Mr Musk described himself as a “moderate Democrat” until recently but became a vocal critic of the party during the Biden administration.