I think you can set hero levels (or at the very least their experience) even when they are dead. I currently do that in my map with no problem.
However, another solution if level up functions don't work for dead heroes could be to add a boolean flag "shouldLevelUp[playerNumberHere]" (or w/e name) and set it to true for dead heroes when a boss is defeated.
When a hero respawns, check if that boolean is true and add a level, then set the flag to false. Or, per Warseeker, store the "current team level" as an integer and always set levels on respawn. I think there are a few ways to fix this. Did you try setting levels already for dead heroes?