Merge bones into one bone and retain weights

I want to merge bones into one single bones, but I want the remaining bone to have all weights from all the bones. Can blender do this?

Yeah, but it’s more tedious than it should be, at least in out-of-the-box Blender. You can use a vertex weight mix modifier to add weights from one group to another. After adding all the weights onto a single bone (and applying the modifiers), you can delete the other bones, or make them non-deforming.

Of course this is scriptable, and I’d be surprised if there aren’t any addons/scripts to do the process for you.