Yes, there is a quite simple way to do this!
First, place your expand-script in a good folder, like /usr/local/bin/expand.sh
, and make it executable with chmod +x /usr/local/bin/expand.sh
Then, edit /boot/config.txt
and add the following furthest down:
[expansion]
init=/usr/local/bin/expand.sh
Reboot, and then observe the expanded filesystem with df -h