The Lagrangian density of any field theory does not need to by polynomial in the field. The polynomial form of a Lagrangian density is typically taken to be an approximation in the spirit of effective field theory. Indeed, one could easy write down a field theory whose Lagrangian density takes the form
This theory is known as Sine-Gordon theory (for obvious reasons). In $d=2$ dimensions Sine-Gordon theory is actually incredibly interesting and has many applications in the study of duality.
Of course, I could simply Taylor expand the cosine and write
which resembles the form in which you wrote your Lagrangian density.
The polynomial approximation is typically taken because one cannot do traditional perturbation theory without it (polynomial terms lead to $n$-valent graphs in the Feynman diagrammatic expansion of the partition function in a field theory) and because of the fact that terms in the Lagrangian with high powers of $\varphi$ typically are less important in certain approximation regimes (this is the basis of effective field theory).
I hope this helps!