Ferrari posted higher sales and earnings in the third quarter and said it was more confident that it would hit its annual guidance, racing ahead of other car makers that are grappling with weakening sales amid a slower-than-expected shift to electric vehicles and challenges in China.