Generally, there is no way. But if you know, there is no user/pid namespaces involved, there is a simple heuristic.
This investigation risen from my explanation that shebang is processed by the kernel (in Linux). I was very proud of myself able to explain such obscure topic like exec formats. But there was an innocent question: what about scripts without shebang? How kernel knows…