$$ y''+ a[\sin(y)]+ b[\cos(y)] =f(x) \tag 1$$
$a[\sin(y)]+ b[\cos(y)]=\rho \sin(y+\phi)\quad\text{with}\quad \begin{cases}\rho=\sqrt{a^2+b^2}\\ \tan(\phi)=\frac{b}{a} \end{cases}$
Change of function :$\quad y(x)=u(x)-\phi\quad$ transform Eq.(1) into Eq.(2) :
$$u''+\rho\sin(u)=f(x) \tag 2$$
Change of variable :$\quad t=\sqrt{\rho}\:x\quad\to\quad \frac{d^2u}{dt^2}+\sin(u)=\frac{1}{\rho}f\left( \frac{t}{\sqrt{\rho}}\right)$
Let $\quad F(t)=\frac{1}{\rho}f\left( \frac{t}{\sqrt{\rho}}\right).\quad$ Since $\rho$ and $f$ are known, $F(t)$ is a known function.
$$\frac{d^2u}{dt^2}+\sin\left(u(t)\right)=F(t) \tag 3$$
Probably, no simpler form of equation (with no parameter inside) can be derived.
In the particular case $F(t)=0$ the solution can be expressed in terms of Jacobi elliptic function.
In the case $F(t)=C\neq 0$, Eq.(3) is an ODE of the autonomous kind. But the integration cannot be done in term of standard special functions.
A fortiori, in the general case $F(t)$ not constant, there is no closed form for the solution of the ODE.
This doesn't mean that closed form never exists in some particular cases. Just look backwards : Put a given function $y(x)$ into Eq.(1). This gives a particular function $f(x)$. For this function $f(x)$ , at least a closed form solution exist for Eq.(1) : the $y(x)$ a-priori chosen.
Thus, no definitive answer can be given to the question raised. This depends on the explicit definition of the function $f(x)$. But it is clear that analytical solving Eq.(1) is not possible in general.
You can neither express all lines in terms of a function $y(x)$ nor express all lines in terms of a function $x(y)$, since in each case there are lines that aren't described by such functions. This is a matter of the form in which you represent the functions, not of the differential equations that you impose on that form.
All lines can be represented in the form $(x(s),y(s))$, where $s$ is an arc length parameter, and in this representation the differential equation for lines is $\frac{\mathrm d^2}{\mathrm ds^2}(x(s),y(s))=0$.
Best Answer
The equation of any non-vertical line in the plane is $y = ax + b$, where $a \in \mathbb{R}$ and $b \in \mathbb{R}$. Therefore, the differential equation will be $y' = a$, for all $a$.
EDIT: I let this slip by, we can in fact have $a$ as zero. As Mathguy pointed out, this means all horizontal lines. Sorry.