Elon Musk’s legal battle against OpenAI has hung over the ChatGPT maker for more than two years, threatening to unravel its restructuring as a for-profit business and undermine its plans to go public.