I want to create an app which will allow the user to generate a virtual RFID card, add it to the Apple Wallet app, and later be scanned by some RFID scanner.
For example, my gym has an iOS app. After signing in, I can generate an "Access Pass" and add it to Wallet. It prompts me to "Hold Near Reader" and can open the door to my gym
How can I add this same functionality to my own app?
You are probably not going to be able to do this. iOS doesn't make HCE (Host card emulation) available generally.
With a specific entitlement from Apple you can add passes to Apple Wallet that support Value-Added-Services (VAS). These can be read by NFC readers that support the Apple VAS protocol.
My supermarket loyalty card works this way; Because the supermarket chain is large they can ensure that the required firmware is installed in their POS readers.
If you are interested in pursuing this then you should start with Loyalty and membership passes on Apple platforms - That page contains details of pass providers that you can work with and NFC readers that support VAS