Sam Altman and Elon Musk, the OpenAI cofounders turned rivals, are locked in a legal battle over the direction of the company.