Lewis Hamilton secured his first Sprint pole since the 2021 season in just his second race weekend with Ferrari in Shanghai.