It is narrated from Sayyiduna Jabir (may Allah be pleased with him) that once the Prophet (peace and blessings be upon him) said while delivering a sermon: When any one of you comes while the Imam is delivering the sermon, he should still perform two rak‘ahs.
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 15180
Hadith Gradingحکم دارالسلام:حديث صحيح، وهذا إسناد قوي م: 875