FREMONT, Calif.—Dressed in the same black Tesla Inc. T-shirt that he wore when he entered his car factory three days earlier, Elon Musk sat beneath fluorescent lights in a cluster of desks near the body shop.

On a chair next to him was a white caseless pillow that he used while sleeping on the floor under his desk. The billionaire CEO and chairman of the electric-car maker wasn’t far from two general assembly lines making the Model 3 sedan, surrounded by the sound of banging metal.

Outside,...