I would not replace only some cells in a stack. They are all old, even though some may not have failed yet. This means they have aged to a lower capacity. You will be creating a severe capacity mismatch. Depending on the protection provided, or not provided, by the battery management hardware/software, you will then experience overcharging, since the weak cells will charge to a higher voltage first, meaning the voltage applied across the pack will be higher for the weak cells, leading to ... fire and explosion. In discharge, the old cells will be depleted first, leading to critically low voltage for them, leading to copper deposition and subsequent ... fire and explosion.
Don't do it.