There are many stories, such as an account that one year when there was a person missing for the minyan in Chevron for the Yamim Neoraim Avraham Avinu showed up to be the tenth, (an angel? with Rav Chaim Volozhin) of people and/or being who are no longer alive, answering brachos and being the tenth to a minyan. Would does this actually work halachically?
The Sefer Chassdim siman 1129 writes that Rebbi after he passed away wpuld come dressed in his shabbas clothes and recite kiddush rabbah for his family and be motzei them. The question that is asked how can he be motzei his family if the passuk in tehillim states bmeisim chafshi. The answer that is given is from the gemara in brachos 18a that Tzadikim are called alive even while they are deceased. So in theory a tzadik that comes back seems like they cam be motzei others simce they are called alive. There is also a story about Rav Yose Haglili( Sefer Yechusei Tannaim and Amoraim (chelek 2: Reb Yossi Haglili) making havdalah for his family as well.
Text of Sefer Chassidim: