You receive the error "Realm <realm_name> is referenced by policy" when trying to delete an authentication realm.
The authentication realm is currently referenced within the current configuration.
Before a realm can be deleted from the configuration, it has to be clear of any reference in the policy and it can't be part of a sequence realm.
Verify the realm is not a part of any sequence realms.
Navigate to Configuration > Authentication > Sequences > Sequence Main, toggle through each sequence realm from the drop-down, and delete the realm if it is present.
Try to delete the realm by issuing the delete realm command with the force option in the command line interface (CLI):
#(config) security iwa delete-realm realm_name force
SGOS may be holding a reference to it in memory. Reboot the device to clear it.