How to make viewmodel sway?

I would like viewmodel sway but I am confused on how to get the result I want.
What I want is this

There is a really helpful framework tutorial that at some point in the tutorial weapon sway is added and that might be useful