This should indeed be possible with a Custom Container since you can install all required dependencies and not run into limitations of the shared environment where functions usually run on.
This blog covers this for Python but the parts of the dockerfile related to selenium could be reused.