onBootstrap not called for CLI commands

May be a dirty solution, but it worked! I created a factory for the url view helper, which is exactly as the original in ViewHelperManagerFactory, just without the route match part. I guess it works, because I do not use matched route part of the helper (since there is none).

<?php

namespace System\View\Helper;

use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\ServiceManager;
use Laminas\View\Helper\Url;

class UrlFactory
{
    /**
     * @param ContainerInterface|ServiceManager $container
     * @return Url
     */
    public function __invoke(ContainerInterface $container)
    {
        $urlHelper = new Url();
        $urlHelper->setRouter($container->get('HttpRouter'));
        return $urlHelper;
    }
}

and the custom cli config:

<?php

use Laminas\Mvc\Service\ServiceManagerConfig;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Stdlib\ArrayUtils;

$config = require __DIR__ . '/../../../config/application.config.php';
$extendedConfig = [
    'service_manager' => [
        'factories' => [
            ZfcTwig\View\TwigRenderer::class => System\View\TwigRendererFactory::class,
        ],
    ],
    'view_helpers' => [
        'factories' => [
            \Laminas\View\Helper\Url::class => \System\View\Helper\UrlFactory::class,
        ]
    ]
];
$container = new ServiceManager();
(new ServiceManagerConfig())->configureServiceManager($container);
$container->setService('ApplicationConfig', $config);
/** @var \Laminas\ModuleManager\ModuleManager $moduleManager */
$moduleManager = $container->get('ModuleManager');

$events = $moduleManager->getEventManager();
$events->attach(\Laminas\ModuleManager\ModuleEvent::EVENT_MERGE_CONFIG, function (\Laminas\ModuleManager\ModuleEvent $e) use ($extendedConfig) {
    $configListener = $e->getConfigListener();
    $config = $configListener->getMergedConfig(false);
    $config = ArrayUtils::merge($config, $extendedConfig);
    // Pass the changed configuration back to the listener:
    $configListener->setMergedConfig($config);
});
$moduleManager->loadModules();

return $container;

I hope there will be no more troubles on the way. @froschdesign thans again for your help. If I everything else works, could I mark two of your answers as solutions (to this and the initial problems)?