Can we execute custom Python functions from driver expressions?
Your custom driver must add itself to the list of drivers BPY is aware of.
See the example here:
https://docs.blender.org/manual/en/dev/animation/drivers/workflow_examples.html#driver-namespace

import bpy

def driverFunc(val):

    return val * val    # return val squared

bpy.app.driver_namespace['driverFunc'] = driverFunc    # add function to driver_namespace