I have two coordinate frames of reference. The second one is different from the first one in that the $x$ and $z$ axes are interchanged.
If I get a quaternion representing a rotation in the first frame and I want to find the equivalent in the second frame, can I simply swap the $x$ and $z$ quaternion values?
That is, $q_1= [q_1.w, q_1.x, q_1.y, q_1.z]$ in the first frame becomes
$q_2= [q_2.w, q_2.z, q_2.y, q_2.x]$ in the second frame
Generally, when two axes are exchanged, but all orientations stay the same otherwise, then the coordinate system handedness changes and $q_2.w$ must be assigned the value of $-q_1.w$ in order to maintain rotation correctness (or, alternatively, the sign of $q.w$ may remain the same, but the signs of all other components must be flipped).
So, based on the information you provided, I'd assume $q_2=[-q_1.w, q_1.x, q_1.z, q_1.y]$