How to create a mirror pose for a pose bone (using Python)?
OK, I probably have butchered all the rules for doing matrix math, but it works.

Basically, multiply the bone to have mirror matrix then scale it back, but it is now in reverse orientation, pointing towards opposite direction. 

To counter this, I rotate it 180 long z and y axis. For some reason, updating / refreshing scene was needed for this to work.

This yields the rotation I was looking for (so far it seems to work like intended):

def mirrorPose(bone):
    m = bone.matrix.Diagonal((-1,1,1,0))
    bone.matrix = m @ bone.matrix
    bone.scale = (1,1,1)

    bpy.context.view_layer.update()

    z = mathutils.Euler((0,0,math.radians(180))).to_matrix().to_4x4()
    bone.matrix = bone.matrix @ z
    bpy.context.view_layer.update()

    y = mathutils.Euler((0,math.radians(180),0)).to_matrix().to_4x4()
    bone.matrix = bone.matrix @ y