Covering the head is in fact the Sunnah of the Messenger (ﷺ)  and the practice of the Companions radillahu anhum

Shaikh al-Albani rahimahullah wrote:

وليس من الهيئة الحسنة في عرف السلف اعتياد حسر الرأس والسير كذلك في الطرقات والدخول كذلك في أماكن العبادات بل هذه عادة أجنبية تسربت إلى كثير من البلاد الإسلامية حينما دخلها الكفار وجلبوا إليها عاداتهم الفاسدة فقلدهم المسلمون فيها فأضاعوا بها وبأمثالها من التقاليد شخصيتهم الإسلامية

“And it is not from the good appearance in the custom of the Salaf to habitually uncover the head and walk like that in the streets and enter like that into the places of worship. Rather, this is the custom of the foreigners that infiltrated into many of the lands of Islam when the disbelievers entered and brought to them their evil custom. So the Muslims blindly followed them in it. So it was wasted by this blind following and its likes the Islamic personality…”

[Tamam al-Minna pg. 164]

Shaikh ul-Islaam Ibn Taymiyyah rahimahullah said:

وأما كشف الرءوس والانحناء فليس من السنة . إنما هو مأخوذ عن عادات بعض الملوك والجاهلية والمخلوق لا يسأل كشف رأس ولا ركوع له .وإنما يركع لله في الصلاة وكشف الرءوس لله في الإحرام

“As for uncovering the heads and bowing [to others] then they are not from the Sunnah. Verily they are taken from the customs of some of the kings, from the period of ignorance, and from the creation that do not ask about uncovering the heads nor about bowing. Verily bowing is only for Allah in prayer and uncovering the head is for Allah in state of Ihraam”

[Majmoo’ al-Fatawa (11/554)]

He also said rahimahullah:

وأما كشف الرؤوس , وتفتيل الشعر , وحمل الحيَّات , فليس هذا من شعار أحد من الصالحين , لا من الصحابة ولا التابعين , ولا شيوخ المسلمين , لا المتقدمين ولا المتأخرين

“As for uncovering the heads, tying the hair, and carrying snakes, then this is not from the signs of any of the pious. Not the Companions, nor Tabi’een, nor Shuykh of the Muslims, nor the early generations, nor the latter generations..”

[Majmoo’ al-Fatawa (11/269)]

So we see that uncovering the head is not from the Sunnah nor the practice of the Companions radillahu anhum and those after them. In fact, the Prophet (ﷺ) used to cover his head:

Proof:

عَنْ جَعْفَرِ بْنِ عَمْرِو بْنِ حُرَيْثٍ، عَنْ أَبِيهِ، قَالَ رَأَيْتُ النَّبِيَّ ـ صلى الله عليه وسلم ـ يَخْطُبُ عَلَى الْمِنْبَرِ وَعَلَيْهِ عِمَامَةٌ سَوْدَاءُ ‏

It was narrated from Ja’far bin ‘Amr bin Huraith that his father said, “I saw the Prophet (ﷺ) delivering a sermon on the pulpit, wearing a black turban”.

[Saheeh Ibn Majah no. 2901]

As for the cap (قلنسوة ) then the Salaf used to wear it.

Proofs:

Imam Ibn Qayyim rahimahullah said:

وكان يلبس القلنسوة بغير عمامة ، ويلبس العمامة بغير قلنسوة

“He (ﷺ) used to wear a cap without a turban and a wear a turban without a cap”

[Zad al-Ma’ad (1/130)]

Also,

عَنْ هِلاَلِ بْنِ يِسَافٍ، قَالَ قَدِمْتُ الرَّقَّةَ فَقَالَ لِي بَعْضُ أَصْحَابِي هَلْ لَكَ فِي رَجُلٍ مِنْ أَصْحَابِ النَّبِيِّ صلى الله عليه وسلم قَالَ قُلْتُ غَنِيمَةٌ فَدَفَعْنَا إِلَى وَابِصَةَ قُلْتُ لِصَاحِبِي نَبْدَأُ فَنَنْظُرُ إِلَى دَلِّهِ فَإِذَا عَلَيْهِ قَلَنْسُوَةٌ لاَطِئَةٌ ذَاتُ أُذُنَيْنِ وَبُرْنُسُ خَزٍّ أَغْبَرُ وَإِذَا هُوَ مُعْتَمِدٌ عَلَى عَصًا فِي صَلاَتِهِ فَقُلْنَا بَعْدَ أَنْ سَلَّمْنَا ‏.‏ فَقَالَ حَدَّثَتْنِي أُمُّ قَيْسٍ بِنْتُ مِحْصَنٍ أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم لَمَّا أَسَنَّ وَحَمَلَ اللَّحْمَ اتَّخَذَ عَمُودًا فِي مُصَلاَّهُ يَعْتَمِدُ عَلَيْهِ

Hilal ibn Yasaf said, “I came to ar-Raqqah (a place in Syria). One of my companions said to me, ‘Do you want to see any of the Companions of the Prophet (ﷺ)?’ I said. ‘A good opportunity’. So we went to Wabisah. I said to my friend. ‘Let us first see his mode of living’. He had a cap with two ears stuck (to his head), and wearing a brown silken robe. He was resting on a staff during prayer. We asked him (about resting on the staff) after salutation; He said. ‘Umm Qays, daughter of Mihsan said to me that when the Messenger of Allah (ﷺ) became aged and the flesh grew increasingly on him, he took a prop at his place of prayer and rested on it’.

[Saheeh Sunan Abi Dawood no. 948]

Even in the Musannaf Ibn Abi Shaybah, there is the chapter:

فِي لُبْسِ الْقَلانِسِ

About wearing Caps

In there, he mentions rahimahullah some narrations of the Salaf wearing the cap.

So it is something well-known. However, it must be mentioned that wearing a cap is a Sunnah of custom and not a Sunnah of worship. Covering the head is from the Sunnah and the way of Islam, but one can do so with whatever is custom in his land and is not prohibited of imitating the disbelievers.

Shaikh al-Albani rahimahullah said:

بأننا نقول أن ذلك ليس من السنة أي السنة التعبدية وكذلك نقول هذه الألبسة التي كان يلبسها الرسول عليه السلام هي من عادة البيئة وعادة العرب الذي هو عليه الصلاة والسلام منهم فهذه العمامة كانت قبل بعثة الرسول عليه السلام بل قبل خلقه

“We say that it is not Sunnah, that is, a Sunnah of worship. Likewise, these clothing which the Messenger (ﷺ)  wore is from the custom of the environment and the custom of the Arab which he (ﷺ)  was from. So this turban was there before the Messenger(ﷺ) was sent. Rather before he was created…

Then he goes on to say:

خلاصة القول ثبت هذا اللباس عن الرسول عليه السلام العمامة والقلنسوة والإنسان في ذلك حر شاء فعل هذا أو غير ذلك

“So the conclusion of the statement is that these clothing are established from the Messenger (ﷺ), the turban and the cap. A person is free in that. If he wills this or other than that”.

[Mutafarriqaat no. 141]

The Shaikh rahimahullah also mentioned the same in Silsilatul-Huda wan-Nur no. 487.

And Allah Knows Best

Faisal Ibn Abdul Qaadir Ibn Hassan
Abu Sulaymaan