How many different factions can cast the spell? As The_Silent said the buff itself won't 'remember' who cast it so you're gonna need a more complex trigger. However, if you only have 1 faction that can cast the spell, you can vastly simplify by transferring all units that die with the buff to 1 specific player's control and your trigger becomes much easier.
Another problem might be: do any of the units that 'die' and have their faction changed have items, are they heroes with levels and abilities, or are there any triggers that may pertain to that specific unit? If that's the case then you're going to need to actually prevent them from dying instead of just catching when they die (lazy trigger), which is definitely harder.
Finally are you looking for a GUI solution or are you okay with JASS or vJASS code?
Edit Actually if you need it for N different factions you could make N different buffs and N copies of the ability which each apply a specific one of those N buffs so you know exactly which faction the dying unit should be converted to.