The Prophet ﷺ said, "When you see a funeral procession, stand up for it, and whoever follows it should not sit down until it is placed on the ground."
حدثنا يحيى بن سعيد عن هشام حدثنا يحيى عن أبي سلمة
عن النبي ﷺ قال إذا رأيتم الجنازة فقوموا لها فمن اتبعها فلا يقعد حتى توضع
Its isnad is sahih, Bukhari related it 2/107, in the book of funerals, chapter of whoever follows a funeral procession should not sit, and Muslim 2/659 no. 958, in the book of funerals, chapter of standing for the funeral procession.