If I was you, I’d put your spray Pattern in a curve (Vector/2D Vector).
Store it in your weapon.
In your player, store a variable called “recoil”, preferably a float in [0,1]
In your weapon, store a variable called "recoil falloff " again as a float in [0,1].
In your weapon, also store a variable called “recoil effect”, preferably [0,1/amount of bullets in round]
In your player Event Tick, “recoil” is decreased by recoil falloff of your currently equipped weapon.
Whenever the player shoots, get the position from your recoil curve with your current “recoil” and add “recoil effect” of your weapon to the current “recoil” of the player.
Add the value from the curve at the specified position to your player View
This is an idea I came up now. It certainly is not the CSGO-Spray algorithm, but it’s a start…