Do a translate followed by a rotate followed by a translate
Can also obtain the equivalent of keystrokes gxx5 rzz45 gxx5, (ie local transform on x by 5, rotate on z by 45 degrees, local transform again by 5), by creating transform and rotation matrices, and chaining them together via matrix multiplication in the order wanted.

import bpy
from mathutils import Matrix
from math import radians

# Translation matrices
T0 = T1 = Matrix.Translation((5, 0, 0))

# Rotation matrix
R0 = Matrix.Rotation(radians(45), 4, 'Z')

obj = bpy.context.object

#  
M = T0 * R0 * T1

obj.matrix_world = M * obj.matrix_world