Need to Override a whitelisted and sanitized function

I want to override the following function, which is both whitelisted and sanitized.
I tried using the override_whitelist_method hook, but it doesn’t seem to work.

Is it possible to override it using hooks?. Or are there any other alternatives?

@thomasantony12

Just use a monkey patch to override the function — override_whitelisted_methods won’t work reliably in this case.