To add to VesuvianPrime’s great answer, since you have a Transform, you can use localToWorldMatrix to create your matrix. I think it’s the same as Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale).
However, you can’t just plug that into your current GizmoDrawLine. But you could use it like this to make a frame around an object and follows its rotation:
public static void GizmoDrawLine(float gap, Transform t)
{
var line = 0.07f;
Gizmos.color = Color.red * 0.5f;
Gizmos.matrix *= t.localToWorldMatrix;
var height = new Vector3(line, line + gap * 2f, line);
var width = new Vector3(line + gap * 2f, line, line);
Gizmos.DrawCube(Vector3.right * gap, height);
Gizmos.DrawCube(-Vector3.right * gap, height);
Gizmos.DrawCube(Vector3.up * gap, width);
Gizmos.DrawCube(-Vector3.up * gap, width);
}