The Prophet ﷺ said, "When one of you comes to the prayer while the imam is in some position, let him do as the imam is doing."
حدثنا هشام بن يونس الكوفي حدثنا المحاربي عن الحجاج بن أرطاة عن أبي إسحق عن هبيرة بن يريم عن علي وعن عمرو بن مرة عن ابن أبي ليلى
قال النبي ﷺ إذا أتى أحدكم الصلاة والإمام على حال فليصنع كما يصنع الإمام
No references are available.
[Its chain is daif]. Baghawi also reported it in Sharh al-Sunnah, hadith no. 825, from the hadith of Tirmidhi through the same route, and its chain is daif due to several flaws, among them that Hajjaj bin Artah is daif and a mudallis. The hadith has daif corroborating narrations found in Abu Dawud, hadith no. 506, and elsewhere.