Example 6 Let $n(n \geqslant 2)$ be a given positive integer. Find the smallest real number $\lambda(n)$, such that for any real numbers $x_{1}, x_{2}, \cdots, x_{n}$ satisfying $x_{1}+2 x_{2}+\cdots+n x_{n}=0$, we have
$$
\left(\sum_{i=1}^{n} x_{i}\right)^{2} \leqslant \lambda(n)\left(\sum_{i=1}^{n} x_{i}^{2}\right) .
$$
【Analysis】First, transform the condition into
$$
\alpha \sum_{i=1}^{n} x_{i}=\sum_{i=1}^{n}(\alpha-i) x_{i},
$$

where $\alpha$ is a constant to be determined.
Squaring both sides of equation (1) and applying the Cauchy-Schwarz inequality to the right side, we get
$$
\begin{array}{l}
\left(\sum_{i=1}^{n} x_{i}\right)^{2} \\
\leqslant\left[\frac{n(n+1)(2 n+1)}{6 \alpha^{2}}-\frac{n(n+1)}{2 \alpha}+n\right] \sum_{i=1}^{n} x_{i}^{2} .
\end{array}
$$

Completing the square, we get
$$
\frac{n(n+1)(2 n+1)}{6 \alpha^{2}}-\frac{n(n+1)}{2 \alpha}+n
$$

The minimum value of this expression is $\frac{n^{2}-n}{4 n+2}$, which is achieved when $\alpha=\frac{2 n+1}{3}$.
By the equality condition of the Cauchy-Schwarz inequality, it is easy to see that when $x_{i}=\frac{2 n+1}{3}-i(i=1,2, \cdots, n)$,
$$
\lambda(n) \geqslant \frac{n^{2}-n}{4 n+2} .
$$

Thus, $\lambda(n)_{\min }=\frac{n^{2}-n}{4 n+2}$.