Run a script/perform an action upon scale down?

Hello all - quick questions:

I’m running a custom service catalog based on the community catalog with a MongoDB entry. I have Scale Up working perfectly but scale-down operation breaks database replica sets (HostUnreachable) so I need to remove the missing member from the replica set.

When a scale-down operation is performed, are any processes/shell scripts triggered? Is the entrypoint processed?

I’ve searched around but don’t seem to be able to find an answer.

Thanks much!