Hi, so the better way I was thinking of above was more of a comment on how to organize your code. But the way to define a swap gate, even for two different sites, is always the same: you define a tensor and set certain elements equal to 1.0 such that the action of the tensor on your two sites results in the states being swapped afterward. Diagrammatically this looks like two identity tensors "braided" with each other.
However, I have another suggestion for you which I learned from my summer intern, Yiqing Zhang. She had the nice idea of using the fact that the ITensor SVD lets you put which indices go to the "left" and the "right" when implicitly reshaping a tensor as a matrix. So say you have two MPS tensors with site indices s1 and s2. So you have two neighboring tensors with indices like A(l1,s1,l2) and A(l2,s2,l3). Now multiply these together to get the "bond tensor" B(l1,s1,s2,l3). Now SVD this B tensor back apart, grouping l1 and s2 together to go onto "U" and s1 and l3 to go onto V. So like B(l1,s2,s2,l3) = U(l1,s2,a) S(a,a') V(a',s1,l3). Now re-form the MPS as [U] [SV]. The result is that s1 and s2 have been swapped and you skip the overhead of having to make and apply a gate - you can just go straight to the SVD step which has to be done anyway!