In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
Answering your question, the Fatwa Center at Islam Q and A, states:
It is prescribed to offer duaa (supplication) for the Muslims, males and females, seeking the best of this world and the Hereafter for them. This is one of the meanings of the brotherhood and bonds of faith that exist among Muslims.
A Muslim should love for his brother what he loves for himself of good. Hence he should pray for all the Muslims, seeking the best of this world and the hereafter for them.
Ibn Masud (may Allah be pleased with him) said: When we prayed behind the Prophet (peace be upon him), we used to say: Peace (salam) be upon Jibreel and Mika’eel, peace be upon So and so and So and so. The Messenger of Allah (peace be upon him) turned to us and said: “Allah is as-Salam, so when one of you prays, let him say: al-Tahiyyatu Lillaahi wa’l-salawatu wa’l-tayyibat; al-salaamu ‘alayka ayyuha’l-nabiyyu wa rahmat-Allahi wa barakatuhu; al-salamu ‘alayna wa ‘ala ‘ibad-illah il-saliheen (All compliments, prayers and good words are due to Allah; peace be upon you, O Prophet, and the mercy of Allah and His blessings; peace be upon us and upon the righteous slaves of Allah).” (Al-Bukhari and Muslim)
If the Muslim intends to offer duaa for a particular person, then offers duaa for the Muslims in general, there is hope that his duaa will benefit all of them.
Abu Hurairah said: The Messenger of Allah (peace be upon him) offered the funeral prayer and said: “O Allah, forgive our living and our dead, our young and our old, our male and our female, our present and our absent ones. O Allah, whomever You give life among us, cause him to live as a believer and whomever You cause to die among us, cause him to die in Islam. O Allah, do not deprive us of his reward and do not cause us to go astray after that. (Abu Dawud)
Al-Qari (may Allah have mercy on him) said:
“At-Tibi said: What is meant by the four pairs [in the hadith quoted above] is to include everyone; it is not be interpreted as being only for these four pairs. It is as if he is saying: O Allah, forgive the Muslim men and women, all of them.” (Mirqat al-Mafateeh (3/1208)
Ibn Allan (may Allah have mercy on him) said:
“O Allah, forgive our living and dead” means: all of our living and dead, among the Muslims.” (Daleel al-Faliheen, 6:416)
We read in Fiqh al-Ad`iyah wal-Adhkar, 3:232:
“This is a great supplication which includes the one for whom the funeral prayer is being offered, as well as other Muslims, both living and dead, young and old, male and female, those who are present and those who are absent, because they all share the same need and, indeed, the necessity of Allah’s forgiveness, pardon and mercy.”
Almighty Allah knows best.