Which Sunnah Prayer Can You Offer at Forbidden Prayer Times?
Question

What are the times when it is makruh to pray, and what Sunnah prayers may one pray at times when prayer is makruh?
Praise be to Allah.Times when prayer is forbidden
The times when (voluntary or nafl) prayer is not allowed are basically three, and five ‘when explained in detail. They are: 

From dawn until sunrise
From sunrise until the sun has risen to the height of a spear, which is approximately twelve minutes, but to be on the safe side we make it a quarter of an hour.
When the sun is high at noon, until it passes the zenith.
From `Asr prayer until sunset.
When the sun begins to set until it is fully set.

In brief, the times are: 

From dawn until the sun has risen to the height of a spear
When high at noon, until it has passed the zenith
From `Asr prayer until the sun has fully set.

When is nafl prayer not allowed?
During these times, voluntary prayer is not allowed . With regard to offering obligatory prayers or making them up , the prohibition has nothing to do with that. 
“The basic principle is that voluntary prayers are prescribed at all times , because of the general meaning of the verse in which Allah, may He be exalted, says (interpretation of the meaning):
“O you who believe! Bow down, and prostrate yourselves, and worship your Lord and do good that you may be successful.” [Al-Hajj 22:77]
And the general meaning of the words of the Prophet (blessings and peace of Allah be upon him) to the man who had done a favour for him. The Prophet (blessings and peace of Allah be upon him) said: “Ask.” He said: I ask to be in your company in Paradise. The Prophet (blessings and peace of Allah be upon him) said: “Is there anything else?” He said: That’s it (i.e., I do not ask you for anything else). He said: “Then help me to help you by prostrating a great deal.” Based on that, the general principle concerning voluntary prayer is that it is prescribed at all times, for the one who is at home and the one who is travelling, but there are some times during which the Lawgiver has disallowed prayer, and these times are five…” (Ash-Sharh al-Mumti‘ by Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) 
Which sunnah prayer can you offer at disliked prayer times?
A number of jurists made exceptions for some types of nafl prayer at times when prayer is not allowed . They are: 

The two rak‘ahs following tawaf (circumambulation of the Ka`bah). That is because of the report narrated by at-Tirmidhi (868), an-Nasai (2924), Abu Dawud (1894), and Ibn Majah (1254) from Jubayr ibn Mut‘im, according to which the Prophet (blessings and peace of Allah be upon him) said: “O Bani ‘Abd Manaf, do not prevent anyone from circumambulating this House or praying at any time he wants of the day or night.”. The hadith was classed as sahih by al-Albani in Sahih at-Tirmidhi. 


Repeating a prayer in congregation. If a person has offered the obligatory prayer, then he comes to a mosque and finds the congregation praying, he may pray with them, even if that is at a time when prayer is disallowed, and his prayer with them will be nafl. That is because of the report narrated by at-Tirmidhi (219) and an-Nasai (858) from Yazid ibn al-Aswad al-‘Amiri who said: I was present with the Prophet (blessings and peace of Allah be upon him) during his Hajj, and I prayed Fajr with him in the mosque of al-Khayf. Then when he had finished his prayer and left, he saw two men at the back of the people who had not prayed with him. He said: “Bring them to me.” They were brought, trembling, and he said: “What kept you from praying with us?” They said: O Messenger of Allah, we had already prayed in our camp. He said: “Do not do that. If you have prayed in your camp and you come to the mosque of a congregation, pray with them, and it will be nafl for you.” The hadith was classed as sahih by al-Albani in Sahih at-Tirmidhi. 


The Sunnah following Dhuhr prayer if one is putting Dhuhr together with `Asr – it is permissible to do it after `Asr. The Prophet (blessings and peace of Allah be upon him) was distracted and did not offer the Sunnah prayer after Dhuhr, so he prayed it after `Asr. It was narrated by al-Bukhari (1233) and Muslim (834) that the Prophet (blessings and peace of Allah be upon him) said to Umm Salamah: “O daughter of Abu Umayyah, you asked about the two rak‘ahs after `Asr. Some people from Banu ‘Abd al-Qays came to me, and they distracted me from praying the two rak‘ahs that come after Dhuhr; these are they (i.e., I prayed them now).” 


One who comes in on Friday when the imam is delivering the khutbah; he may pray two brief rak‘ahs, even if that is at the time when the sun is high. That is because of the report narrated by al-Bukhari (931) and Muslim (875) from Jabir, who said: A man came in on Friday when the Prophet (blessings and peace of Allah be upon him) was delivering the khutbah. He said: “Have you prayed?” He said: No. He said: “Get up and pray two rak‘ahs.” 


The funeral prayer may be offered during the lengthy times when prayer is not allowed, according to scholarly consensus, i.e., after Fajr prayer until the sun rises and after `Asr prayer until the sun sets. 

Ibn Qudaamah (may Allah have mercy on him) said: 
“The funeral prayer may be offered. With regard to offering the funeral prayer after Fajr prayer until the sun rises and after `Asr until the sun sets, there is no difference of scholarly opinion concerning it. Ibn al-Mundhir said: The consensus of the Muslims is that the funeral prayer may be offered after `Asr and Fajr. 
With regard to offering the funeral prayer at the three times mentioned in the hadith of ‘Uqbah ibn ‘Amir, that is not permissible. This was mentioned by al-Qadi and others. Al-Athram said: I asked Abu ‘Abdullah about offering the funeral prayer when the sun has just risen. He said: As for (doing so) when the sun has just risen, I do not like that. Then he quoted the hadith of ‘Uqbah ibn ‘Amir. 
A similar opinion was narrated from Jabir and Ibn ‘Umar. This was quoted by Malik in al-Muwatta from Ibn ‘Umar. And al-Khattabi said: This is the view of the majority of scholars. 
Abu’l-Khattab said, narrating a different report from Ahmad, that offering the funeral prayer is permissible at all times when prayer is disallowed. And this is the view of ash-Shafi'i, because it is a prayer that is permitted after Fajr and `Asr, so it is permitted at all times, like the obligatory prayers. 
But ‘Uqbah ibn ‘Amir said: There are three times at which the Messenger of Allah (peace and blessings be upon him) forbade us to pray or to bury our dead. The fact that he mentioned the prayer along with burial indicates that what is meant is the funeral prayer, because it is a prayer other than the five obligatory prayers, so it is not permissible to do it at these three times, as is the case with all nafl prayers in general. Rather it is permitted after Fajr and `Asr because these periods may be lengthy and waiting may not be convenient, but these three other periods are brief. With regard to the obligatory prayers, they cannot be taken as an analogy, because they have to be done, and it is not valid to draw an analogy between these three times and the other two times, because the prohibition in this case (the three times) is clearer and they are shorter, so there is no fear for the deceased in this case. Moreover, it is forbidden to bury the deceased at this time, and when the prayer is mentioned in conjunction with the burial, this signifies that what is meant is the funeral prayer, unlike the other two times.” (Al-Mughni, 1/425)
The wording of the hadith of ‘Uqbah ibn ‘Amir (may Allah be pleased with him) is: “There are three times when the Messenger of Allah (blessings and peace of Allah be upon him) told us not to pray or bury our dead: when the sun begins to rise until it is high, when it is standing directly overhead at noon, and when it has started to set, until it has set.” (Narrated by Muslim, 831) 
Can you offer nafl prayers done for a particular reason at forbidden times?
The jurists differed concerning some of the nafl prayers and whether it is prescribed to do them at a time when prayer is not allowed or not. One of their differences has to do with nafl prayers that are done for a specific reason, such as “greeting the mosque” (tahiyyat al-masjid ) and the Sunnah prayer following wudu. Some of them said that it is permissible to do them at times when prayer is not allowed; this is the view of ash-Shafi'i (may Allah have mercy on him), and was favoured by a number of the scholars, and it is the more correct view. And some of the scholars disallowed that and did not differentiate between general nafl prayers and nafl prayers that are done for a specific reason. 
And Allah knows best.