Can you use USB OTG and charge at the same time?
I've found that that feature depends on the kernel. So wether your phone can charge and use OTG depends on the kernel on your phone. If it doesn't support it out of the box, you can try to find and flash a custom kernel with that functionality. The OTG cable also plays an important factor.

However, similar question was asked about the Nexus 7, which doesn't have support, it is highly likely that your Pixel 2 also doesn't support it.

This should answer your question and give you more insights of how and why.