How would I go about doing gun sway on movement with a viewport?

Hey there! I would like to figure out how I would go about doing gun sway when the player moves with a viewport model.

If you can help please reply!