From my understanding, work done against gravity would be work that is applied in opposition to gravity (the opposite direction the gravity is pulling towards); whereas work done by gravity would simply be in the direction gravity is pulling towards.
Lets say you have a ball with a mass hanging by a rope, then the work done by gravity would just be mgh (m being mass, g the gravitational acceleration, and h being the height), from U (potential energy) = mgh. The work done against gravity in order for the ball to stay stationary would have to be an equivalent force in the opposite direction, -mgh. Therefore, in this case the work done against gravity = work done by gravity, which is the case of a simple stationary system.
However, even if you were to drop a ball from a point A to a final position of B, with a displacement of r for instance, (because of gravity being a conservative force, the work done would just be the work done from point A to point B) the work done by gravity on the ball would be the force times the dot product of the change in displacement, as from:
$$\int_A^B F \bullet dr = mgh = mg (A-B)$$
and if this is a closed system where energy is conserved,
where $K_1$, $K_2$ are the initial and final kinetic energies respectively, and $U_1$ and $U_2$ are the initial and final potential energies respectively, so the equation stated by you above would technically be correct, except that there would be no change in mechanical energy if energy is conserved, work done against gravity = work done by gravity by your definition.