It doesn’t make sense to run a container just for breaking out and running a script on the host, but you can run an API service on the host and send a request to it from the container.
By “breaking out” I mean you could run a privileged container, disable pid namespace and attach to all of the namespaces of PID 1 and execute a script there. It is much better to use an API and let the API service execute the script on the host.
Are those NodeRED modules? Actually that would be the best way if you could install everything in a Docker image. But I don’t use NodeRED and I don’t really know anything about it so I could be wrong, although one of the reasons we are using containers is that we can have a portable image with all the modules and libraries and we can create and remove containers any time without installing anything on the host which would require installing dependencies that can break something.