Elon Musk was dealt a significant setback in a court fight over compensation sought by the top Twitter Inc. executives he fired when he took over the company in 2022.