Check out the [line 114 of duo script](https://github.com/GluuFederation/oxAuth/blob/master/Server/integrations/duo/DuoExternalAuthenticator.py#L114):
And then the [getCountAuthenticationSteps method](https://github.com/GluuFederation/oxAuth/blob/master/Server/integrations/duo/DuoExternalAuthenticator.py#L193)
If you don't want to use LDAP groups, you could use an attribute of the user.
Another solution would be to upgrade to 4.1.1, use Casa, and let the user set their own policy regarding 2FA.