In Joomla 4 you can use the WebAsset Manager instead of HTMLHelper(JHtml).
In your template's index.php file:
$wa = $this->getWebAssetManager();
$version = filemtime(JPATH_ROOT . '/media/templates/site/mytemplate/css/mymain.css');
$wa->registerAndUseStyle('template.mytemplate.mymmain', "mymain.css", ['version' => $version, 'relative' => true], ['rel' => "preload", 'as' => "style", 'onload' => "this.rel='stylesheet'" ], []);
in this example code, my css file is called: mymain.css and it is in media folder under templates/site/mytemplate/css subfolder as it should be. This has worked for me.
It is same with HTMLHelper:
use Joomla\CMS\HTML\HTMLHelper;
$version = filemtime(JPATH_ROOT . '/media/templates/site/mytemplate/css/mymain.css');
HTMLHelper::stylesheet('mymain.css', $options = ['version' => $version, 'relative' => true, ], $attribs = ['rel' => "preload", 'as' => "style", 'onload' => "this.rel='stylesheet'"]);
result:
<link href="/media/templates/site/mytemplate/css/mymain.css?1681564883" rel="preload" as="style" onload="this.rel='stylesheet'" />