XamlWriter is not supported by maui.
You will need to use an xmlwriter to create a uncompiled Xaml form as xml. Also Xaml forms are compiled for Maui, you will probably need the Xaml forms just as xml to be able to read.
you then use the Xaml extension method LoadFromXaml() to parse and load an xml string as a Xaml form.
https://learn.microsoft.com/en-us/dotnet/maui/xaml/runtime-load?view=net-maui-8.0
Your approach seems wrong. you should be using Maui themes.