Is there some way I can start a (repeating) ping while the network is unreachable?

You can use a while loop in a shell script:

failed=1 # any number not equal to zero
while [ $failed -ne 0 ]
do
   ping -n 8.8.8.8
   failed=$?
done
# after the  $? becomes "0" it will get out of the while loop
echo "ping succeeded"

To stop keep printing the connect: Network is unreachable message you can edit the line with ping like this:

ping -n 8.8.8.8 2> /dev/null

Or you can add a sleep in the loop to reduce the number of those messages.

The script can be simplified to

while ! ping -n 8.8.8.8
do
    sleep 1
done

Which lets it be written in one line:

while ! ping -n 8.8.8.8; do sleep 1; done