How can I add a variables to my page.html.twig file?
There is no index called header_attributes inside $variables array no need to create it, there is page index just use it:
Try this out:

function [yourThemeName|yourModuleName]_preprocess_page(&amp;$variables){
  $variables['page']['header_attributes']['class']= 'myClassHere';
}


Note don't forget to clear cache.
In your twig you will get your class by:

page['header_attributes']['class']