There are several providers that offer an iMessage service, like https://loopmessage.com/ and https://sendblue.co/. You could also go through Apple directly, although the process and API are not publicly defined.
Another approach and mechanism can be seen in this repo https://github.com/ZekeSnider/Jared, where you can interact with the iMessage database directly and script a device to handle inbound and outbound messages.