If you want correct values, you have to take into account the effects mentioned in Brandon Rhodes' answer. Nevertheless, here's how to do a quick-and-dirty calculation.
The absolute magnitude of a planet is defined as the apparent magnitude if the Sun-planet and planet-observer distances are 1 au, at opposition.
Assuming a diffuse disc reflector model, the absolute magnitude $H$ of a planet of diameter $D_{\rm p}$ is given by
$$H = 5 \log_{10} \left( \frac{D_0}{D_{\rm p} \sqrt{a_p}} \right)$$
Where $a_p$ is the planet's geometric albedo, and $D_0$ is given by
$$D_0 = 2\,{\rm au} \times 10^{H_\ast / 5}$$
Where $H_\ast$ is the absolute magnitude defined at a reference distance of 1 au, which can be calculated from the usual 10 parsec absolute magnitude $M_\ast$ as follows:
$$H_\ast = M_\ast + 5 \log_{10} \left( \frac{1 \rm \ au}{10 \rm \ pc} \right) \approx M_\ast - 31.57$$
For the Sun, this results in $D_0 \approx 1329\ \rm km$.
To get the apparent magnitude of the planet, you can then use
$$m_{\rm p} = H + 5 \log_{10} \left( \frac{d_{\rm p\ast} d_{\rm po}}{1 \mathrm{\ au}^2} \right) - 2.5 \log_{10} q(\alpha)$$
Where $d_{\rm p\ast}$ is the distance between the planet and the star, $d_{\rm po}$ is the distance between the planet and the observer, and $q(\alpha)$ is the phase integral at the phase angle $\alpha$.
For the diffuse disc reflector, $q(\alpha) = \cos \alpha$. For a Lambertian sphere,
$$q(\alpha) = \frac{2}{3} \left( \left(1 - \frac{\alpha}{\pi} \right) \cos \alpha + \frac{1}{\pi} \sin \alpha \right)$$
At opposition, $\alpha = 0$, giving phase integrals of $q(0) = 1$ for the diffuse disc, and $q(0) = \tfrac{2}{3}$ for the Lambertian sphere.
Real planets have more complex phase functions which need to be determined empirically (see Brandon Rhodes' answer).
As a quick check, let's plug in values for Jupiter, taken from the NASA Jupiter Fact Sheet. With a (volumetric mean) diameter of 139,822 km and a geometric albedo of 0.538, the computed absolute magnitude is -9.44, versus the actual value of -9.40.
Using the computed value of -9.44, a distance from Jupiter of 5.204 au to the Sun and 4.204 au to the Earth, and using the Lambertian sphere $q(0) = \tfrac{2}{3}$, the apparent magnitude works out at -2.30, while for a diffuse disc $q(0) = 1$ the apparent magnitude works out at -2.74. The brightest the real planet gets is around -2.94. Fortunately for me, the value comes out in the right ballpark, despite the gross approximations being made to the reflection behaviour of real planets.
My computed values using $q(0) = 1$ for Saturn, Uranus and Neptune are 0.54, 5.57 and 7.75 respectively, which aren't too far off the real values either.