Euclid: Constraining ensemble photometric redshift distributions with stacked spectroscopy