I've seen this "derivation" before. You first start with the EOM (Newton's second law) for a particle at the boundary of the sphere
$$m\ddot{r}=-\frac{GMm}{r^2}.$$
If we eliminate $m$, substitute $\ddot{r}=\ddot{a}x$ and $M=\displaystyle\frac{4}{3}\pi r^3\rho$ we get to
$$\ddot{a}x=-\frac{4\pi G}{3}\rho\ r$$
and dividing by $x$ to
$$\ddot{a}=-\frac{4\pi G}{3}\rho\ a.$$
We can integrate this equation by noticing that $\displaystyle\ddot{a}=\frac{d\dot{a}}{dt}=\frac{d\dot{a}}{da}\frac{da}{dt}=\frac{d\dot{a}}{da}\dot{a}$, therefore
$$\int\dot{a}d\dot{a}=-\int\frac{4\pi G}{3}\rho\ ada\tag{1}$$
Now, integrating $(1)$ will give you a constant on one side of the equation, let's name it $C$:
$$\frac{\dot{a}^2}{2}=-\frac{4\pi G}{3}\int\rho_0\frac{1}{a^2}da$$
$$\frac{\dot{a}^2}{2}=\frac{4\pi G}{3}\rho_0\frac{1}{a}+C$$
$$\frac{\dot{a}^2}{2}=\frac{4\pi G}{3}\rho\ a^2+C.$$
The constant $C$ must have the same dimensions as the other two terms in the last equation, i.e. it must have dimensions of $[T]^{-2}$. Hence, nothing prevents me from writing the constant $C$ as
$$C\equiv \frac{kc^2}{2},$$
where $c$ is the speed of light (with dimensions $[L]/[T]$)and $k$ is a curvature, i.e. it's something that has dimensions of curvature $([L]^{-2})$. By making this renaming of the constant of integration, you arrive to the Friedmann equation in the way it is usually stated (as derived from General Relativity).
$$\left(\frac{\dot{a}}{a}\right)^2=\frac{8\pi G}{3}\rho-\frac{kc^2}{a^2}\tag{2}$$
From here, to show the relation between $k$ and $U$ that you state just multiply both sides by $a^2x^2/2$, you get
$$\frac{1}{2}\dot{a}^2x^2=\frac{4\pi G}{3}\rho a^2x^2-\frac{1}{2}kc^2x^2.$$
Now since $v=x\dot{a}$ and $\rho=\displaystyle\frac{M}{\displaystyle\frac{4}{3}\pi r^3}$
$$\frac{1}{2}v^2=\frac{4\pi G}{3}\displaystyle\frac{M}{\displaystyle\frac{4}{3}\pi r^3} r^2-\frac{1}{2}kc^2x^2$$
$$\frac{1}{2}v^2=\frac{GM}{r}-\frac{1}{2}kc^2x^2$$
$$\frac{1}{2}v^2-\frac{GM}{r}=-\frac{1}{2}kc^2x^2.$$
Finally, identify the LHS with the total energy per unit mass $U/m$ and solve for $k$.
One last bit, the interpretation of $k$ is done in the same way as in general relativity. First, we know experimentally that $\dot{a}>0$ at the present time, i.e., the Universe is expanding right now. By looking at equation $(2)$, we see that if $k<0$ the RHS of Eq. $(2)$ will be positive at all times, indicating that $\dot{a}(t)>0$ for all $t$ and the Universe will expand forever. To see this more clearly, rewrite the Friedmann equation as
$$\dot{a}^2=\frac{8\pi G}{3}\frac{\rho_0}{a}-kc^2.\tag{3}$$
Notice how for $a\rightarrow\infty$, $\dot{a}^2$ approaches a constant value $-kc^2$. If $k=0$, then the RHS of Eq. $(2)$ will also be positive forever, but in such a way that the expansion eventually stops at very large $a$, cf. Eq. $(3)$, $$\dot{a}\rightarrow 0\, \text{ as } a\rightarrow\infty\quad (k=0).$$
Finally, if $k>0$, the RHS of Eq. $(2)$ will vanish at a value of $a_{max}=\displaystyle\frac{8\pi G\rho_0}{3kc^2}$. At that point the expansion will stop and the Universe will start contracting $(\dot{a}<0)$. The sign of $k$ then, separates Universes that expand forever from Universes that recollapse in the future.