Since the election, Elon Musk had largely appeared inseparable from the president, helping to reshape government and root out fiscal waste.