Python, How to get pose bone to rotate with another pose bone from a different armature? Finding Rotational difference
Object.convert_space
As mentioned in previous answer there is a convenience method available on the object that converts space.
Rather than totally doing my head in by trying to make a rotation difference am going to

Convert source and target pose bone matrices to world space
Decompose them, ie get their world space location, rotation and scale parts.
Recompose the target world matrix to have rotation part of source
Convert this to pose space of target bone and set as matrix.

Test method.
import bpy
from mathutils import Matrix

def snap_rotation(source, target):
    Ms = source.id_data.convert_space(
        pose_bone=source,
        matrix=source.matrix,
        from_space='POSE',
        )
    Mt = target.id_data.convert_space(
        pose_bone=target,
        matrix=target.matrix,
        from_space='POSE',
        ) 
         
    _, q, _ = Ms.decompose()
    t, _, s = Mt.decompose()
    M = (
        Matrix.Translation(t) @
        q.to_matrix().to_4x4() @ 
        Matrix.Diagonal(s.to_4d())
        )
    target.matrix = target.id_data.convert_space(
        pose_bone=target,
        matrix=M,
        to_space='POSE',
        )    

if __name__ == &quot;__main__&quot;:
    context = bpy.context
    scene = context.scene
    snap_rotation(
        scene.objects[&quot;Armature&quot;].pose.bones[&quot;Bone&quot;],
        scene.objects[&quot;Armature.001&quot;].pose.bones[&quot;Bone&quot;]
    )