To reach the final result, you can follow these detailed steps:
Write the double-angle formula
$$
\sin x = 2 \sin\frac x2 \cos\frac x2
$$
and repeat using that formula so that we can get
$$
\sin x = 2^n \sin\frac{x}{2^n} \prod_{i = 1}^{n} \cos\frac{x}{2^i} \quad (n \in \mathbb{Z}^*). \tag{$*$}
$$
Divide both sides of $(*)$ by $x$ (given $x > 0$), then take the limit of both sides of the equation when $n \to \infty$. Note that the change of value of $n$ has no effects on LHS, so we get
$$
\frac{\sin x}{x}
= \lim_{n \to \infty} \Big(
\frac{\sin(x / 2^n)}{x / 2^n} \prod_{i = 1}^{n} \cos\frac{x}{2^i}
\Big)
= \prod_{i = 1}^{\infty} \cos\frac{x}{2^i}.
$$
This is the result Tien Kha Pham provided directly. (Note that $\prod_{i = 1}^{\infty} \cos(x / 2^i)$ makes sense only if the corresponding limit $\lim_{n \to \infty} \prod_{i = 1}^{n} \cos(x / 2^i)$ exists.)
To relate this result to the form of Viète's formula you mentioned in the question, substituting $x = \pi / 2$ with formulas
$$
\cos \Big(\frac{\pi}{4}\Big) = \frac{\sqrt{2}}{2}
\quad\text{and}\quad
\cos \Big(\frac{x}{2^k}\Big) = \frac 12 \sqrt{2 + 2\cos \Big(\frac{x}{2^{k - 1}}\Big)} \quad (k \ge 2),
$$
we finally conclude with
$$
\frac{\pi}{2} = \prod_{k = 2}^{\infty} a_k,
$$
where $a_2 = \sqrt{2} / 2$, $a_3 = \sqrt{2 + 2a_2} / 2 = \sqrt{2 + \sqrt{2}} / 2$ and $a_{k + 1} = \sqrt{2 + 2a_k} / 2$ for $k \ge 3$.
Once there was a minor mistake in the answer made by Tien Kha Pham. The typo no longer existed. But another consequent mistake, in the comment to that answer, will remain. Therefore I keep the following words visible only as a reminder for those who may get confused by the inconsistency between formulas.
Just a correction to the answer of Tien Kha Pham (since I don't have
enough reputation to add a comment): it should be $$ \frac{2}{\pi} =
\prod_{k = 2}^{\infty} \cos \Big( \frac{\pi}{2^k} \Big), $$ of which
the $\pi$ appears in numerator, not denominator.