can I manipulate HTML using document via GTM (google tag manager) template, I want to put some html using GTM template but unable to find way to change HTML Please help me in this issue thanks in advance
I assume that you are talking about custom templates in GTM. Custom templates use "sandboxed Javascript", basically a Javascript dialect that prevents the script in your templates from doing security-relevant stuff. Amongst other thing, scripts in custom templates cannot access the DOM (except in a very limited fashion via the injectScript and sendPixel APIs, which require you to configure permissions for allowed destinations).
Sandboxed JavaScript is a simplified subset of the JavaScript language that provides a safe way to execute arbitrary JavaScript logic from Google Tag Manager's custom templates. To provide a safe execution environment, some features of JavaScript are restricted or removed. ...
Sandboxed JavaScript is not executed in the standard global execution environment like normal JavaScript, so the window object and its properties are not available. This includes methods defined in the global scope like encodeURI or setTimeout, global values like location or document, and global values defined by loaded scripts.
Instead of a custom template you would have to use a custom HTML tag. This sounds similar, but has hugely different implications for performance and security (Custom HTML runs standard javascript through eval). Accessing the DOM also causes repaints/reflows, which is bad for performance in general and for Google's new "Web Vitals" metrics in particular, so you SEO ranking might suffer from this.
So, accessing the DOM does not work in custom templates, and is not recommended via custom HTML. If you insist on doing it through a custom HTML tag, it's just standard JavaScript, nothing specific to GTM.