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$.