Hi Bert,
Solution 1
I also faced same issue when upgrading it from v9.0 to v10.0 their are some defect's in 10.0.0 release in reading macro definition so I applied hot-fix 10.0.2 for this issue
Form engine - Script tags not working in custom form layouts10.0.2 for more detail check
https://devnet.kentico.com/download/hotfixes
After applying this hotfix version your existing syntax for localization work's fine.
<h2><%= CMS.Helpers.ResHelper.GetString("Title1") %></h2>
Solution2
Check with this instead of using # use = as in error message it specify you can used it like variable.
<%= Localize("Text containing localization expressions: {$stringKey$}") %>
My recommendation apply latest hotfix to avoid such kind defect's for other features and functionality.
Feel free to ask ! I m happy to assist you :)
Thanks
Prashant