A top Treasury official plans to resign after a fight with Elon Musk’s allies over access to a sensitive payment system.