Rotate bone using python
Rotate an edit bone
To define a rotation require the angle to rotate, the axis to rotate around and a point that the axis goes thru.  To code transforms in 3D the sooner we get our heads around linear algebra, ie vectors and matrices the easier it becomes.
Following test script rotates the edit bone (in edit mode) named &quot;Bone&quot; 30 degrees around the bones local X axis, using its head as the pivot point.
One translation matrix moves such that the head is (0, 0, 0) our pivot point. Rotate this with rotation matrix. Move back with negated transform matrix.
import bpy
from mathutils import Matrix
from math import radians

context = bpy.context

bone_name = &quot;Bone&quot; # change to suit

ob = context.edit_object
arm = ob.data

#bone = context.active_bone
bone = arm.edit_bones.get(bone_name)

if bone:
    # local axes of the bone
    x, y, z = bone.matrix.to_3x3().col
    # rotation matrix 30 degrees around local x axis thru head
    R = (Matrix.Translation(bone.head) @
         Matrix.Rotation(radians(30), 4, x) @
         Matrix.Translation(-bone.head)
        )
    #bone.matrix = R @ bone.matrix
    bone.transform(R) 

adjust the angle, the axis, the pivot point  to demo how it works. Using y for axis should &quot;roll&quot; the bone.