Might be as easy as e.g.
InParty("Keldorn") >>>> change to BeenInParty("Keldorn")
But, there is the issue that many NPCs have more than one epilogue depending on e.g. romance status, choose essence or not, reputation gained, InParty("someotherNPC") and lot more. This may lead to showing more than one epilogue for NPCs long gone from the party or some weird choice.
Technical feasibility is always one thing with mods, making real sense in the game is another.
Maybe an idea could be to do it for your selected NPCs and combine it with
InParty >>> show epilogue1
!InParty but BeenInParty >>>> show epilogue2
Dead but BeenInParty >>>> show epilogue3
!InParty and !BeenInParty >>> nothing
I do this for my githyanki companion who leaves for home when the Five are dead at ToB battle but before Melissan is defeated. Her epilogue is shown even if no longer InParty but when the global to check she was in the final fight is true.