Before "Baruch She’amar," we recite the verse, "Hashem Melech, Hashem Malach, Hashem Yimloch Le’olam Va’ed." We recite this verse twice, followed by the verse, "Ve’haya Hashem Le’melech Al Kol Ha’aretz…"
Rav Haim Palachi (Turkey, 1788-1869), in his Kaf Ha’haim (18:7), discusses the situation of a person who hears the congregation recite "Hashem Melech" while he is at a different point in the prayer service (listen to audio recording for precise citation). He writes that one is required to stand when the congregation recites "Hashem Melech," and, if he is at a point where interruptions are allowed, he must interrupt his prayer to join in the congregational recitation of "Hashem Melech." Thus, for example, if a person is reciting the Korbanot section, or if he has completed the Amida prayer, and he hears the Hazan and congregation recite "Hashem Melech," he must stand and recite the verses together with the congregation. If, however, one is in the middle of Pesukeh De’zima, for example, when the congregation recites "Hashem Melech," he should not interrupt his prayer, since interruptions are forbidden during Pesukeh De’zima, but he must stand.
Hacham Ovadia Yosef, in his Yabia Omer, questions Rav Haim Palachi’s ruling requiring one to interrupt his prayer for the recitation of "Hashem Melech" in some situations. He cites the Sha’ar Ha’kavanot as stating explicitly that although one must stand when the congregation recites "Hashem Melech," one is not required to recite it along with them if he is at a different point in the prayer service. This is also the view of the Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909). Therefore, one must stand when the congregation recites "Hashem Melech," but he is not required to recite the verses with them, even if he is at a point where interruptions are permitted.
The Kaf Ha’haim Sofer (Rav Yaakov Haim Sofer, Baghdad-Israel, 1870-1939) also follows this view, and adds that this Halacha applies to the recitation of "Hashem Melech" during the Selihot service, as well. Then, too, one who hears "Hashem Melech" must stand throughout the recitation of this paragraph, even if he is at a different point in the Selihot service. However, standing is not required when one hears "Hashem Melech" recited during the Hakafot service on Simhat Torah, as is the accepted custom. The recitation of "Hashem Melech" during the Hakafot does not require everyone to stand.
Summary: One who hears the congregation recite the verses of "Hashem Melech" before "Baruch She’amar" or during Selihot must stand throughout the recitation of that brief portion of the prayer service, even if he is currently reciting a different part of the service. He does not, however, have to join in the recitation, even if he is at a part of the service where interruptions are allowed. One does not have to stand when hearing the recitation of "Hashem Melech" during Hakafot on Simhat Torah.