Praise be to Allah, and may peace and blessings be upon the Messenger of Allah. To proceed:
First: Allah Does Not Punish Anyone Before the Proof Has Been Established Against Him
The texts of the Qur’an and Sunnah indicate that Allah تعالى does not punish anyone until the message reaches them and the proof has been established against them. Allah تعالى says:
“And We would never punish until We had sent a messenger.” [Al-Isra: 15]
And He سبحانه says:
“Messengers bringing good news and warnings, so that mankind would have no argument against Allah after the messengers.” [An-Nisa: 165]
It is authentically reported in Sahih Muslim that the Prophet ﷺ said that whoever among the Jews and Christians hears of him and then dies without believing in what he was sent with will be among the people of Hell. This indicates that whoever was not reached by the message in a manner that establishes the proof against him does not have the same ruling as someone who received the message and then rejected it.
As for those who were not reached by the call of Islam in an authentic manner that establishes the proof, the stronger opinion held by a group of scholars is that they will be tested on the Day of Resurrection. Whoever obeys will enter Paradise, and whoever disobeys will enter Hell.
Second: What About Gog and Magog?
It is established through authentic texts that Gog and Magog are disbelievers and that they are among the people of Hell. In an authentic hadith, it is stated that out of every thousand people who are brought forth for reckoning, nine hundred and ninety-nine will be from Gog and Magog.
The hadiths also indicate their corruption and tyranny upon the earth, and that when they emerge, they will besiege Jesus, peace be upon him, and the believers who are with him, until Allah تعالى destroys them.
There is no explicit authentic text that tells us how the call of the Prophet ﷺ reached them, or whether his message reached them directly or whether the call of one of the previous prophets reached them. However, the established fact that they are disbelievers indicates that they were not among those upon whom the proof had absolutely never been established.
It is possible that the call of the Prophet ﷺ reached them in a way unknown to us, or that the message of one of the prophets who came before the Prophet ﷺ reached them and they rejected it. It is not correct to assert details for which there is no evidence.
Conclusion:
The basic principle is that Allah تعالى does not punish anyone until the proof has been established against them. Whoever was not reached by the call of Islam in a manner that establishes the proof has the ruling of the people who lived during a period without a messenger, according to the stronger opinion, and will be tested on the Day of Resurrection.
As for Gog and Magog, it is established that they are disbelievers and among the people of Hell, but we do not possess an authentic text specifying how the message reached them. Therefore, one should not go into details for which there is no established evidence.
And Allah knows best.