I finally worked it out. I needed to create a session and assign it to the app before getFormToken would work. So first I use the Joomla session:
use Joomla\Session\Session;
Then create the session, set it and get the form token:
$session = Session::getInstance('none');
$this->app->setSession($session);
$token = $this->app->getFormToken();
Easy when you know how! I hope this helps someone else.