Edit. After a conversation with Fedya I improve my previous answer. Let $f(x)=\sum_{k=1}^nA_n\cos nx$. If $f(x)\leq 1$, then $A_k\leq 2.$ This is the best possible estimate which holds for all $n$. For fixed $n$ it can be improved, but this is difficult. Proof. We want to maximize $$A_k=\frac{2}{\pi}\int_0^\pi f(x)\cos kxdx$$ under the conditions that $$\int_0^\pi f(x)dx=0,\quad\mbox{and}\quad f(x)\leq 1.$$ It is clear that the maximizing function is $f^*(x)=1-\pi\delta$, where $\delta$ is the delta function representing the unit point mass at some point $x_0$ where takes its smallest value $\cos kx_0=-1$. And the $k$-th Fourier coefficient of $f^*$ is $2$. Edit 2. Another version of this problem is obtained by replacing the restriction $f(x)\leq 1$ by the restriction $|f(x)|\leq 1$. In this case, the estimate will be $|A_n|\leq 4/\pi$, and this is also best possible in the class of all such trigonometric sums with any $n$.