Let $M(x, y) = y^2$ and $N(x, y) = 3xy - \cos(y)$. Then, $$\frac{\partial}{\partial y}M(x, y) = 2y \qquad \text{ and } \qquad \frac{\partial}{\partial x}N(x, y) = 3y$$
We can see that this equation is not exact, however, note that $\frac{N_x - M_y}{M} = \frac{3y - 2y}{y^2} = \frac{1}{y}$ is a function of $y$ only. Thus, there is an integrating factor $\mu(y)$ that satisfies the differential equation $$\frac{\mathrm{d}\mu}{\mathrm{d}y} = \left(\frac{N_x - M_y}{M}\right)\mu = \frac{1}{y}\mu \qquad \implies \qquad \mu(y) = y$$
Multiplying our original equation by $\mu(y)$, we have $$(y^3) + (3xy^2 - y\cos(y))\frac{\mathrm{d}y}{\mathrm{d}x} = 0$$
We can see that this equation is exact, since $\frac{\partial}{\partial y}(y^3) = 3y^2 = \frac{\partial}{\partial x} 3xy^2 - y\cos(y)$. Thus, there exists a function $\psi(x, y)$ such that \begin{align*}\psi_x(x, y) &= y^3 \tag{1} \\\psi_y(x, y) &= 3xy^2 - y\cos(y) \tag{2}\end{align*}
Integrating (1) with respect to $x$, we get \begin{align*}\psi(x, y) &= \int y^3 \,\mathrm{d}x = xy^3 + h(y)\end{align*}
for some function $h$ of $y$. Next, differentiating with respect to $y$, and equating with (2), we get $$\psi_y(x, y) = 3xy^2 + h'(y) = 3xy^2 - y\cos(y)$$
Therefore, $$h'(y) = -y\cos(y) \quad \implies \quad h(y) = -y\sin(y) - \cos(y) \quad \implies \quad \psi(x, y) = xy^3 - y\sin(y) - \cos(y)$$
Thus, the solutions of the differential equation are given implicitly by $$\boxed{xy^3 - y\sin(y) - \cos(y) = C}$$
Given the initial value $y(1) = \pi$, we have $\pi^3 + 1 = C$, so the particular solution is $$\boxed{xy^3 - y\sin(y) - \cos(y) = \pi^3 + 1}$$