Keep 'overlay' attributes when merging/flattening?

I might be missing it somewhere, but I’ve googled this to death any can’t find anything. Is there a way to merge or flatten layers, or even just export an image while keeping the layer attributes? For example, if I have a green dithered square and have a red ‘overlay’ layer, it should now be a red dithered square. But when I merge or flatten or export, it just changed the overlay layer into a normal layer and I lose those attributes. I end up with a plain red square as my output.

If you change to RGB mode before exporting it works as far as i have tested i had the same issue with what was meant to be a visor but on index mode it did not see the new colors so i had to use RGB mode