Original linear system
$$
\mathbf{A}x = b
$$
with the matrix $\mathbf{A}\in\mathbb{C}^{n\times n}$, and the data vector $b\in\mathbb{C}^{n}$ is not in the null space $\mathcal{N}\left(\mathbf{A}\right)$. The least squares solution defined as
$$
x_{LS} =\left\{
x \in \mathbb{C}^{n} \colon \lVert \mathbf{A}x - b \rVert_{2}^{2}
\text{ is minimized}
\right\}
$$
Introduce a set of weighting factors $w_{k}$ in the form of an invertible diagonal matrix $\mathbf{D}\in\mathbb{C}^{n\times n}$.
$$
\mathbf{D} = \left[ \begin{array}{ccccc}
\sqrt{w_{1}} \\
& \sqrt{w_{2}} \\
& & \ddots &\\
& & & \sqrt{w_{n}}
\end{array} \right]
$$
The weighted linear system is expressed as
$$
\mathbf{D}\, \mathbf{A}x = \mathbf{D} \, b
$$
The least squares solution is defined as
$$
\tilde{x}_{LS} =\left\{
\tilde{x} \in \mathbb{C}^{n} \colon \lVert \mathbf{D}\, \mathbf{A}\,x - \mathbf{D} \, b \rVert_{2}^{2}
\text{ is minimized}
\right\}
$$
Establish the normal equations:
$$
\left( \mathbf{D} \, \mathbf{A}\right)^{T} \, \mathbf{D} \, \mathbf{A} \, x = \left( \mathbf{D} \, \mathbf{A}\right)^{T} \, \mathbf{D} \, b
\qquad \Rightarrow \qquad
\mathbf{A}^{T} \, \mathbf{W} \, \mathbf{A} \, x = \mathbf{A}^{T} \, \mathbf{W} \,b
$$
Notice
$$
\text{rank } \mathbf{A} = \text{rank } \left( \mathbf{D} \, \mathbf{A} \right)
$$
The weighting does not affect the existence or uniqueness of solutions. The solution is
$$
\tilde{x}_{LS} = \left( \mathbf{A}^{T} \, \mathbf{W} \, \mathbf{A} \right)^{-1} \mathbf{A}^{T} \, \mathbf{W} \, b.
$$
Example
From Data Reduction and Error Analysis for the Physical Sciences, 1e, by Philip Bevington, table 6.1:
$$
\begin{align}
\mathbf{A} x &= b \\
\left[
\begin{array}{cc}
1 & 1 \\
1 & 2 \\
1 & 3 \\
1 & 4 \\
1 & 5 \\
1 & 6 \\
1 & 7 \\
1 & 8 \\
1 & 9 \\
\end{array}
\right]
%
\left[
\begin{array}{cc}
a_{0} \\
a_{1}
\end{array}
\right]
%
&=
%
\frac{1}{10}
\left[
\begin{array}{cc}
156 \\
175 \\
366 \\
438 \\
582 \\
616 \\
642 \\
704 \\
988
\end{array}
\right]
%
\end{align}
$$
The least squares solution is
$$
\left[
\begin{array}{cc}
a_{0} \\
a_{1}
\end{array}
\right]_{LS}
=
\frac{1}{360}
\left[
\begin{array}{cc}
1733 \\
3387
\end{array}
\right]
\approx
\left[
\begin{array}{cc}
4.81389 \\
9.40833
\end{array}
\right]
$$
Introduce the weighting factors
$$
\mathbf{W} =
\left[
\begin{array}{ccccccccc}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & \sqrt{2} & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & \sqrt{3} & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 2 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & \sqrt{5} & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & \sqrt{6} & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & \sqrt{7} & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 2 \sqrt{2} & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 3 \\
\end{array}
\right]
$$
and the least squares solution becomes
$$
\left[
\begin{array}{cc}
\tilde{a}_{0} \\
\tilde{a}_{1}
\end{array}
\right]_{LS}
\approx
\left[
\begin{array}{c}
4.27364 \\
9.49364
\end{array}
\right]
$$