The maximal value is $2\sqrt{n-1}$ if $n$ is odd, and $2\sqrt{n}$ if $n$ is even. We can prove the following:
Let $a_1, \ldots, a_n$ be real numbers, $n \ge 2$. Then
$$ \tag{*}
|a_1 - a_2| + |a_2 - a_3| + \ldots + |a_{n - 1} - a_n| + |a_n - a_1|
\le c_n \sqrt{a_1^2 + \ldots + a_n^2}
$$
where $c_n = 2\sqrt{n-1}$ if $n$ is odd, and $c_n = 2\sqrt{n}$ if $n$ is even. The bounds are sharp.
Proof: Case 1: $n$ is even. Then
$$
|a_1 - a_2| + |a_2 - a_3| + \ldots + |a_{n - 1} - a_n| + |a_n - a_1| \\
\underset{(1)}{\le} \sum_{k=1}^n (|a_k| + |a_{k+1}|) = 2 \sum_{k=1}^n (1 \cdot |a_k|)
\underset{(2)}{\le} 2 \sqrt{n} \sqrt{\sum_{i=1}^{n} a_i^2 } \, ,
$$
where the last step uses the Cauchy-Schwarz inequality.
Equality holds at $(1)$ if the $a_k$ have alternating signs, and equality holds at $(2)$ if all $|a_k|$ are equal. It follows that equality holds in $(*)$ exactly if
$$
(a_1, \ldots, a_n) = (x, -x, \ldots, x, -x)
$$
for some $x \in \Bbb R$.
Case 2: $n$ is odd. There must be (at least) one index $k$ such that $a_{k-1} - a_k$ and $a_k - a_{k+1}$ have the same sign. Without loss of generality $k=n$, so that
$$
|a_{n-1} - a_n | + |a_n - a_{1}| = |a_{n-1} - a_{1}| \, .
$$
Then, using the already proven estimate for the even number $n-1$,
$$
|a_1 - a_2| + |a_2 - a_3| + \ldots + |a_{n - 1} - a_n| + |a_n - a_1| \\
= |a_1 - a_2| + |a_2 - a_3| + \ldots + |a_{n - 1} - a_1| \\
\underset{(3)}{\le} 2\sqrt{n-1} \sqrt{\sum_{i=1}^{n-1} a_i^2 }
\underset{(4)}{\le} 2\sqrt{n-1} \sqrt{\sum_{i=1}^{n} a_i^2 } \, .
$$
Equality holds at $(3)$ if $(a_1, \ldots, a_{n-1}) = (x, -x, \ldots, x, -x)$, and equality at $(4)$ holds if $a_n = 0$. It follows that equality holds in $(*)$ exactly if
$$
(a_1, \ldots, a_n) = (x, -x, \ldots, x, -x, 0)
$$
for some $x \in \Bbb R$, or a cyclic rotation thereof.