Muawiyah (may Allah be pleased with him) narrates: I heard the Messenger of Allah (ﷺ) saying: "When the muezzin said: 'Ashhadu an la ilaha illallah' (I bear witness that there is no god but Allah), the Prophet (ﷺ) also said: 'Ashhadu an la ilaha illallah.' And when he said: 'Ashhadu anna Muhammadan Rasulullah' (I bear witness that Muhammad is the Messenger of Allah), the Prophet (ﷺ) said: 'I also bear witness.' Then he remained silent."
Hadith Referenceمسند الإمام الشافعي / كتاب الصلاة / 169
Hadith Takhrijأخرجه البخارى: الجمعة، باب يجيب الامام على المنبر اذا سمع النداء: 94 ، 612.