No, it is fabricated.
Leading authorities in Hadith have declared this narration to be fabricated.
فَأَكَلَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ بَاذِنْجَانَةً فِي لُقْمَةٍ وَقَالَ: إِنَّمَا الْبَاذِنْجَانُ شِفَاءٌ مِنْ كُلِّ دَاءٍ وَلا دَاءَ فِيهِ “. هَذَا حَدِيثٌ مَوْضُوعٌ عَلَى رَسُول الله صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ
So the Prophet ﷺ ate aubergine in a morsel and said, ‘Indeed aubergine is a cure for every illness and there is no illness in it. This is a fabricated Hadith. (Imam Ibn al-Jowzi, al-Mowdo’aat).
حديث: “أَنَّ النَّبِيَّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ أَكَلَ بَاذِنْجَانَةً فِي لُقْمَةٍ. وَقَالَ: إِنَّمَا الْبَاذِنْجَانُ شِفَاءٌ مِنْ كل داء. هو موضوع.
Indeed, the Prophet ﷺ ate aubergine in a morsel and said, ‘Indeed aubergine is a cure for every illness.’ This is fabricated. (Imam al-Showkani, al-Fawaid al-Majmo’ah).
If someone is claiming that this Hadith is authentic then he or she must prove it. Which means they must reference it to a primary book of Hadith with a sound chain of narrators. It is not acceptable to source a Hadith to a secondary or tertiary book in order to reference it. People who do this, lack knowledge regarding the science of Hadith. Nor is it sufficient to say it has a chain, therefore it is authentic. People who say such things are unaware of even the fundamentals of Hadith science.
And Allah (Most High) Knows best.
– Answered by Shaykh Noorud-deen (23.06.2021)
Is the Hadith, Aubergine is for whatever it is eaten for, fabricated?
Are there authentic Hadith encouraging us to eat aubergine?
See also (video):