The statement is neither hadith nor Qur'an, but one could call it words of wisdom and it will be hard to find a definite source, as there are indeed some similar statements referred to some sophisticated people and scholars.
But it certainly goes along with the teaching of Islam.
We learn to be honest if asked about knowledge in different verses of the Qur'an like in the answer of the Angels when Allah asked them to inform Him about the "names" Allah taught Adam about:
They said, "Exalted are You; we have no knowledge except what You have taught us. Indeed, it is You who is the Knowing, the Wise." (2:32)
From Tafsir al-Qurtobi
Imam al-Qurtobi in his tafsir discussed this saying:
الواجب على من سئل عن علم أن يقول إن لم يعلم : الله أعلم ولا أدري ، اقتداء بالملائكة والأنبياء والفضلاء من العلماء ، لكن قد أخبر الصادق أن بموت العلماء يقبض العلم ، فيبقى ناس جهال يستفتون فيفتون برأيهم فيضلون ويضلون .
It is obligatory for someone who is asked for knowledge he does not possess to say "Allah knows best, I do not know" in imitation of the angels, Prophets and virtuous scholars. The Prophet may Allah bless him and grant him peace, told us however that when the scholars died. true knowledge would disappear and we would be left with ignorant people who would be asked for fatwas and give fatwas according to their own opinion. So they will be misguided and also misguide others.
(source of the translation: tafsir al-Qurtobi Vol1 page 207-208)
Then he started by quoting some narrations and stories of scholars and virtuous and sophisticated people:
Starting with a shortened version of a hadith which was also compiled by al-Hakim in his al-Mustadrak and al-Bayhaqi in his as-Sunan al-Kubra:
وأما ما ورد من الأخبار عن النبي صلى الله عليه وسلم وأصحابه والتابعين بعدهم في معنى الآية فروى البستي في المسند الصحيح له عن ابن عمر أن رجلا سأل رسول الله صلى الله عليه وسلم : أي البقاع شر ؟ قال : لا أدري حتى أسأل جبريل فسأل جبريل ، فقال : لا أدري حتى أسأل ميكائيل ، فجاء فقال : خير البقاع المساجد ، وشرها الأسواق .
(My own translation take it carefully)
Among what has been narrated from our Prophet Allahs prayers and blessings be upon him and his companions and those who followed them in the meaning of this verse is what al-Busti
(referring to ibn Hebban not to abul Fotoh al-Busti the poet from Bost now known as Lashkargah in Afghanistan)
in his musnad as-sahih on the authority of ibn 'Omar that a man came and asked the Messenger of Allah Allahs prayers and blessings be upon him: "What places are the most evil?. He (the prophet()) replayed: I don't know unless after asking Jibreel, then ghe asked Jibreel and Jibreel replayed: I don't know unless I've asked Mikaeel (*) then he came and said: the best places are the mosques and the most evil places the markets.
(*) This is a deviation compared to the ahadith of al-Hakim and al-Bayhaqi, as one narration says:
"I don't know unless I asked my Lord" (al-Mustadrak)
while the other says:
"I don't know. He (referring to the Prophet()) said: "Ask you Lord!" (As-Sunan al-Kubra)
Then he quoted a few statements of the sahaba () -My own translation take it with care-:
- وقال الصديق للجدة : ارجعي حتى أسأل الناس .
Abu Bakr said to the grandmother: go back (home) unitl I ask the people (of knowledge)
- وكان علي يقول : وابردها على الكبد ، ثلاث مرات . قالوا : وما ذلك يا أمير المؤمنين ؟ قال : أن يسأل الرجل عما لا يعلم فيقول : الله أعلم .
And 'Ali used to say: the most cooling for the liver (meaning the most calming or giving peace of mind) -three times- They asked him: What is it O leader of the believers? He answered: It is when a man is asked for knowledge he does not possess and says: Allah knows best
- وسأل ابن عمر رجل عن مسألة فقال : لا علم لي بها ، فلما أدبر الرجل . قال ابن عمر : نعم ما قال ابن عمر ، سئل عما لا يعلم فقال لا علم لي به ذكره الدارمي في مسنده
A man came and asked ibn 'Omar about an issue and he replayed: I don't have knowledge about it, when the man turned away. Ibn 'Omar said: excellent is what ibn 'Omar has said, he was asked about what he had no knowledge about and answered I don't know about it this was also compiled by ad-Darimi in his musnad.
Then he quoted this narration from the introduction of sahih Muslim.
Then he moved on with other quotes:
- وقال مالك بن أنس : سمعت ابن هرمز يقول : ينبغي للعالم أن يورث جلساءه من بعده لا أدري حتى يكون أصلا في أيديهم ، فإذا سئل أحدهم عما لا يدري قال : لا أدري .
Malik ibn Anas said I've heard ibn Hormoz (one of the most influential teachers of Malik ibn Anas) saying: it is obligatory that a scholar hands down to those who sit arround him (his students in first place) after his death "I don't know" to the extent that it would be a foundation (of their knowledge or teaching -my interpretation-), so that if one of them was asked about something he does not know he would answer: I don't know.
- وذكر الهيثم بن جميل قال : شهدت مالك بن أنس سئل عن ثمان وأربعين مسألة فقال في اثنتين وثلاثين منها : لا أدري .
AL-Haytham ibn Jameel said: I witnessed Malik ibn Anas being asked about 48 Issue and he answered 32 out of them by: I don't know.
Then al-Qurtobi moved on comparing these statements with the case of his contemporary scholars, I'd wonder what he would have said if he witnessed our days!
From other sources
Ibn al-Jawzi also quoted in his sayd al-Khawatir a story of Imam Malik: Where a man came to him and asked him about an Issue/for a fatwa and he said: I don't know. The man said: I've traveled a long way to ask you. Malik replayed saying: Go back (home) and tell your people I've asked Malik and he answered: I don't know!
Some more possible sources of this statement (My translation)
- وقال عمر بن عبدالعزيز: مَن قال لا أدري فقد أحرز نصفَ العلم.
'Omar ibn 'Abdal'aziz said: Whoever said I don't know has got half the knowledge.
From the fatwa linked by @Ahmad
- وقال علي رضي الله عنه: ولا يستحي من يعلم إذا سئل عما لا يعلم أن يقول الله أعلم.
'Ali () said: A man of knowledge (scholar) shouldn't be too shy to say Allah knows best if asked about something he doesn't posses knowledge about.
- وقال مالك: من فقه العالم أن يقول لا أعلم.
Malik said: it is part of the fiqh (knowledge, understanding) of scholar to say I don't know.
- قال الشعبي: لا أدري نصف العلم.
A-Sha'aby said I don't know is half of the knowledge. (source)
Earlier scholars used to think twice before giving fatwa:
وقال سفيان: لقد كان الرجل يُستفتَى فيفتي وهو يرعد.
Sufyan said: The man used to be asked (for fatwa) and he was trumbeling while answering.
وقال: من فتنةِ الرجل إذا كان فقيهًا أن يكون الكلامُ أحبَّ إليه من السكوت.
And he said: It is part of the temptation of a man of knowledge if talking is preferred to him than to keep quiet. (source)
There's also a Moroccan proverb saying:
(ما تيتقرقرب غير السطل الخاوي) literally meaning only a empty bucket will give a noise (think of it if you drop something inside). (source)
Which means only a person who has no knowledge would talk a lot.
One could find many other similar narrations of other sahaba, scholars etc. one could also use as an evidence for this going along with the teaching of Islam the verses (16:116), (17:36) and the well known mutawatir hadith.
Some references this article on alukah, this fatwa in Arabic.