Proof. Denote $c={\rm LCM}(a,b)$ and choose $\eta\in \Theta(c)$. Then we may find integers $k,\ell$ such that $w=\eta^k$, $g(w)=\eta^\ell$. So, the polynomial $P(x):=g(x^k)-x^\ell$ has a root $x=\eta$. Thus any element of $\Theta(c)$ is a root of $P$, since cyclotomics are irreducible. For any integer $t$ coprime to $c$ we have $\eta^c\in \Theta(c)$$\eta^t\in \Theta(c)$, so $g(w^t)-(g(w))^t=P(\eta^t)=0$. Try to choose $t$ such that $w=w^{t}$ but $g(w)^t\ne g(w)$, this would yield a contradiction. Our requirements for $t$ are, in other words: $a$ divides $t-1$; but $b$ does not divide $t-1$. Assume that $b$ does not divide $a$, and, if $a$ is odd, then $b$ does not divide $2a$. This allows to choose a prime $p$ such that $s:=\nu_p(b)$ (notation means that $p^s$ is the maximal power of $p$ which divides $b$) satisfies $s>\nu_p(a)$ and either $p$ is odd, or $p=2$ and $s\geqslant 2$. Using Chinese remainders theorem, choose $t$ be congruent to $1+p^{s-1}$ modulo $p^s$ and $t$ be congruent to 1 modulo $c/p^{s}$. Then $t$ is coprime with $c$, $a$ divides $t-1$ but $b$ does not divide $t-1$. This yields a necessary contradiction.
Let now $a>1$ be a divisor of $n$, choose $w\in \Theta(a)$ let. Let $g(w)\in \Theta(b)$. If $a$ is odd and $b$ is an even divisor of $2a$, then $-g(w)\in \Theta(b/2)$. Thus in all cases of Lemma 1 we have $f(w)=\pm w^m$ for certain $m$. Then this equation $f(x)=\pm x^m$ holds for all $x\in \Theta(a)$, since cyclotomics are still irreducible.
We proceed with proving the consistency of signs $\delta_i$ and exponents $m_i$. Let's start with signs. Assume that $\delta_i=-\delta_j$ for some $i<j$. This yields that $x^{m_i}+x^{m_j}$ is divisible by $1+x+\ldots+x^{n/(p_ip_j)-1}$. Substituting $x=1$, we get that $2$ is divisible $n/(p_ip_j)$, that is, $n=p_ip_j$ or $n=2p_ip_j$. In the latter case, if $1<i<j$, then replacing the pair $i<j$ to $1<i$ or $1<j$ in the above argument, we get a contradiction. So, $n=p_ip_j$ or $n=4p_j$. TheseIf $p_1=2$ and $n=2p_2$, then the signs may be chosen consistently because $-1=x$ on $T(2)$. The cases are to be considered separately.$n=pq$ with odd primes $p\ne q$ and $n=4p$ with odd prime $p$ are to be considered separately, this is done at the end of this answer.