Changing rotation_mode from `YXZ` to `XYZ` without changing orientation?
You can use matrices, or quaternions. Unlike euler rotations, matrices or quaternions are comprised values which are order-independent. 

There is no need to apply the "wrong" YXZ rotation to the object. You can store it in an mathutils.Euler object, the convert it to a mathutils.Matrix object and finally convert it back using a different rotation order.

import bpy
import mathutils

ob = bpy.context.active_object

x, y, z = 1, 2, 3

rot_YXZ = mathutils.Euler((x, y, z), 'YXZ')
rot_mat = rot_YXZ.to_matrix()
rot_XYZ = rot_mat.to_euler('XYZ')

ob.rotation_mode = 'XYZ'
ob.rotation_euler = rot_XYZ


The mathutils.Matrix.to_euler method takes the desired rotation order as the first argument.