Exegetes, Sunni and Shi'i, typically understand this verse to refer to the Day of Judgment.
Yawm, when used in this way in the Qur'an, typically refers to the Day of Judgment, as does the verb nab'ath (to resurrect from the dead).
The verses immediately before and after this one also appear to speak about the Day of Judgment; for instance, they speak of the Day when people submit directly to Allah (not a secondary agent, such as the Mahdi), and will see punishment directly from Allah (rather than through a secondary means, such as warfare, which is predicted to occur at the end times).
In this section, it also says that those who associated partners with Allah will see those partners, but this usually does not happen in this world, especially if those partners are non-physical beings such as angels or demigods, or intangible things like digital currency. However, after death, everything is made visible.
So the most likely interpretation is that the verse refers to the Day of Judgment.
Furthermore, to my recollection, narrations about the time of the Mahdi (A) on earth do not speak of witnesses coming from nations and presenting themselves for judgment. Instead, at that time, nations will split up: people will differ individually; some will follow him and some will not.
Rather, the Mahdi will be the witness over everyone since he will ultimately have rule over the planet, and (at least according to Shia belief) he has divinely granted knowledge about everyone.
As for why one witness is mentioned - Possibly, one witness is mentioned for each nation because a single witness will be able to bear witness to the nation as a whole. (On the topic of nations, here are some reflections by 'Allamah Tabataba'i about nations: https://www.al-islam.org/ask/what-have-ahlulbait-as-said-about-nationali...).
It is also narrated from Imam al-Sadiq (A) that every nation and every time has a witness; therefore, if each nation is different at a different time, it may have a witness for each time period. (For instance, Italy might have a witness for the pre-Roman period, the time of the ancient Roman Empire, the Christian Roman Empire, the modern nation-state of Italy, etc.; or those might be treated as different "nations".)
For the Muslim ummah, it is said that the witness is probably the Prophet (S) or the Imams (A), who would have access to knowledge of all the deeds of the nation. Some might argue that the witness is someone else who simply bears witness to the deeds, even if the Prophet and Imams are able to bear witness to all.
So, from all angles, the verse seems to speak about the Day of Judgment. However, as with many ayat of the Qur'an, the exact meaning of the ayah is open to interpretation, and sometimes the important thing is to ponder on what the meaning could be and see what one can take from it.