© ESO 2018. Context. Type Ia supernovae (SNe Ia) are widely used to measure the expansion of the Universe. To perform such measurements the luminosity and cosmological redshift (z) of the SNe Ia have to be determined. The uncertainty on z includes an unknown peculiar velocity, which can be very large for SNe Ia in the virialized cores of massive clusters. Aims. We determine which SNe Ia exploded in galaxy clusters using 145 SNe Ia from the Nearby Supernova Factory. We then study how the correction for peculiar velocities of host galaxies inside the clusters improves the Hubble residuals. Methods. We found 11 candidates for membership in clusters. We applied the biweight technique to estimate the redshift of a cluster. Then, we used the galaxy cluster redshift instead of the host galaxy redshift to construct the Hubble diagram. Results. For SNe Ia inside galaxy clusters, the dispersion around the Hubble diagram when peculiar velocities are taken into account is smaller compared with a case without peculiar velocity correction, which has a wRMS = 0.130 ± 0.038 mag instead of wRMS = 0.137 ± 0.036 mag. The significance of this improvement is 3.58σ. If we remove the very nearby Virgo cluster member SN2006X (z < 0.01) from the analysis, the significance decreases to 1.34σ. The peculiar velocity correction is found to be highest for the SNe Ia hosted by blue spiral galaxies. Those SNe Ia have high local specific star formation rates and smaller stellar masses, which is seemingly counter to what might be expected given the heavy concentration of old, massive elliptical galaxies in clusters. Conclusions. As expected, the Hubble residuals of SNe Ia associated with massive galaxy clusters improve when the cluster redshift is taken as the cosmological redshift of the supernova. This fact has to be taken into account in future cosmological analyses in order to achieve higher accuracy for cosmological redshift measurements. We provide an approach to do so.