Is /Users/Shared preserved after reinstalling the OS?
If you are updating the OS to a newer version, either a point upgrade or 'major version' (e.g. from Catalina to Big Sur), then yes, files in /Users/Shared are left untouched.
I have lots of files in /Users/Shared and have never had them wiped by an OS upgrade.
I haven't use Recovery on a working system, but suspect the results would be the same. An OS installer does not wipe the disk by itself.