Once the call is transferred to the extension, the “die is cast” in terms of how the call will be handled.
If you wanted to write a custom-context, you could probably set up a little program that checked the CID against ASTDB and processed it accordingly.
Take a look at your /var/log/asterisk/full file and find a call that should have gone to voicemail. This will give you the “base” context for your change. At that point, you might be able to add a “custom” version of that context that processes the CID against the database and diverts the call to the ‘h’ part of the context.