Charles Leclerc will partner seven-time world champion Lewis Hamilton at Ferrari next season as Carlos Sainz leaves the team.