How to Pass a Variable to Commerce Order Twig Template
I think this should work, in THEME_NAME.theme add

function THEME_NAME_preprocess_commerce_order_receipt(&amp;$variables) {
  $variables['test'] = "test";
}


Note: replace THEME_NAME with actual name of theme 

Then doing {{ test }} should output "test".

Note: remember to flush all cache to see changes.