Let $n\in\mathbb{N}$ be fixed and denote by $o(k)$ the multiplicative order of $k$ modulo $n$. Define $$p_n(x)=\sum_{\substack{k=1 \\ (k,n)=1}}^n o(k) x^k ;$$here the sum is taken over $k$ that are coprime to $n$, so $o(k)$ is well-defined. Here are two simple observations:
- If $n$ is even, $p_n(x)$ is odd. Further, in this case it only has one real root.
- If $n$ is odd, aside from $n=1$ it seems that $n$ has an even number of real roots. Here is a picture of the number of roots for $1\le n \le 1000$ and $n$ odd.
I checked OEIS and it didn't return any matches. Perhaps this problem is very difficult, as I don't know how easy it is to compute $o(k)$ for arbitrary $n$. If we denote $R(n)$ as the number of real roots of $p_n(x)$ for odd $n$, here are some questions I think are worth pursuing about $R(n$):
- Is there an estimate or asymptotic for $R(n)$? Is there an upper bound for $R(n)$?
- When does $R(n)=2$? For $1\le n\le 1000$, this occured when $n=\{3, 5, 7, 11, 31, 89, 127, 257, 331, 635\}$; OEIS didn't recognize this sequence either.
- As a follow-up, does $R(n)=2$ infinitely often?

$\deg(p_n) = n-1$.
$p_n$ has $2d_n$ non-real roots thus $n-1-2d_n$ real roots counted with multiplicity, maybe you just didn't find the rare cases where it has some double real roots.
For $n$ even then $p_n$ is odd and it is $> 0$ on $(0,\infty)$ thus its only one real root is at $0$.
The same holds when replacing $order(k\bmod n)$ by any non-negative function such that $f(n-1)>0$.
Not convinced that we can say anything about $R(n)$, do more simulations and see if some non-random estimate pops up.