Elon Musk’s electric-vehicle maker also is grappling with soaring inflation and supply-chain disruptions.