Last year, Elon Musk puffed a marijuana blunt during a live-video interview in California. Halfway around the world, executives at Japan’s Panasonic Corp., Tesla Inc.’s automotive battery supplier, watched with alarm.

“What will our investors think?” one Panasonic executive remembers wondering.

Five years after committing to invest billions...