How to batch rename bones and their corresponding vertex groups?
Usually an armature is the parent of the mesh that it deforms (from using &#9096; CtrlP->Automatic Weights), this means we can get the mesh deformed by the armature by looking at it's children property. We can then rename both the bone and vertex group to a new name that is unique among all armatures allowing a conflict free merge. Adding the rig name to the bone name so that "Bone" might become "Leg1_rig_Bone" seems like a good approach.

import bpy

for rig in bpy.context.selected_objects:
    if rig.type == 'ARMATURE':
        for mesh in rig.children:
            for vg in mesh.vertex_groups:
                new_name = rig.name + '_' + vg.name
                rig.pose.bones[vg.name].name = new_name
                vg.name = new_name