Cross-country prodigy Johannes Hoesflot Klaebo suffered his first defeat of the 2017/18 season as he lost a thrilling sprint to Federico Pellegrino in Dresden.