My personal choice, though the camera sway comes from the animations instead of code, so it’s not as clean as doing it algorithmically. It’s drag and drop though, and adds lots of other immersive features for first person (I assume you’re doing a horror game from the reference).
The ones below are really simple to add, but this module lets you make immersive animations without view models and the client-server replication code you’d need for that. If you’re not looking for that, you can use the ones below (though I’d still recommend the foot step sounds from the one above, even if you disable the other features).
These might be good too:
(This one has everything to do with what you’re interested in)
One way of making this is you use a wave function like sine or cosine for the swaying, and use a spring module (Quenty has a great one in nevermore engine that I use) to smooth out the camera animations (a spring basically adds physics in a way, so you set a goal and it “springs” to the goal you set). You can also use the spring to add a “weighty” feel when you rotate the camera that feels immersive.
I would use the things above though, as they’re easier and probably mostly implemented at a fairly skilled level (realism especially).