Yes, the Hanafi scholars recommended reciting Surah Yaseen when visiting a grave based on a Hadith. The Hadith is weak, however weak Hadith can be used for non-obligatory matters according to the vast majority of Ahl al-Sunnah scholars.
عَنْ مَعْقِلِ بْنِ يَسَارٍ، قَالَ: قَالَ النَّبِيُّ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ: اقْرَءُوا يس عَلَى مَوْتَاكُمْ
(Sayidina) Ma’qil ibn Yasar (May Allah Most High be pleased with him) said, the Prophet ﷺ said, ‘Recite (Surah) Yaseen over your deceased.’ (Sunan Abi Dawood 3121, weak, also in Ahmad 20314).
In the Hadith above we find the Holy Prophet ﷺ encouraging the recital of Surah Yaseen upon the deceased. This can be applied to people who visit a grave, because they are in the presence of a deceased individual.
ويستحب للزائر قراءة سورة يس. (مراقي الفلاح)
And it is recommended for the one who visits (a grave) to recite Surah Yaseen. (Imam al-Shurunbulali, Maraaqi al-Falah).
In the Nass (text) above Imam Shurunbulali considers it recommended to recite Surah Yaseen when visiting a grave. In the commentary Imam al-Tahtawi concurs and goes further by mentioning some recommendations as to how to recite.
بعد أن يقعد لتأدية القرآن على الوجه المطلوب بالسكينة والتدبر والاتعاظ. (حاشية على مراقي الفلاح)
(He should recite it) after sitting. So that he can recite Quran according to the required manner, with tranquillity, reflection and admonition. (Imam al-Tahtawi, Haashiyah ala Maraaqi al-Falah).
The Hadith used for the recommendation of reciting Surah Yaseen at a grave is weak. However, weak Hadith can be used for non-obligatory matters according to the vast majority of Ahl al-Sunnah scholars. (See the link below for a more detailed explanation).
عن معقل بن يسار الصحابي رضي الله عنه، أن النبيّ صلى الله عليه وسلم قال: ” اقْرَؤُوا يس على مَوْتاكُمْ “. قلت: إسناده ضعيف، فيه مجهولان
Ma’qil ibn Yasar, the Sahabi, May Allah Most High be pleased with him, said, the Prophet ﷺ said, ‘Recite (Surah) Yaseen over your deceased.’ I (al-Nawawi) say, the chain is weak. It has two unknown narrators. (Imam al-Nawawi, al-Adhkaar).
And Allah Most High Knows Best.
– Answered by Shaykh Noorud-deen Rashid (10.12.2021)
What do the different Hadith classification terms mean?
Using Weak Hadith
See also (video):