(Imām Bukhārī narrates): 'Abdullāh ibn Yūsuf narrated to us, he said: Imām Mālik informed us, from Sumayy, from Abī Sālih, from Abū Hurairah, may Allāh be pleased with him, that the Messenger of Allāh ﷺ said:
When the imām says "Sami'a Allāhu liman hamidah," you say "Allāhumma Rabbanā laka al-hamd," for whoever's saying coincides with the saying of the angels, his past sins will be forgiven.
Reference: Sahih Al Bukhari 796