A court ruled in favor of OpenAI and its chief executive, Sam Altman, in a lawsuit brought by Elon Musk over alleged misconduct in the company's evolution.