Mr. Musk ordered immediate layoffs, fired executives by email and laid down product deadlines, transforming the company.