Yes, you can. One way to do this is to run a web server (e.g. Flask) on the Raspberry Pi, and use the App Inventor Web component to communicate with it, sending HTTP requests and decoding JSON responses. There are some examples in the Raspberry Pi section of the DCU TY App Library.