Lunar soil is made out of rock and dust, with some glasses. Because of this, any laser would have to be powerful enough to heat the sands and other particles such that they melt together. Another option is to vaporize sections of lunar dust, uncovering the color of the rocks below.
Some technical difficulties include the refraction of Earth’s atmosphere, which could bend the laser beam and send it off target. Even though the refraction may only be at a one-degree angle, over the distance of space this results in the laser being off target by a considerable amount. However, we have successfully hit targets on the moon with lasers, such as when we hit a reflector placed by an Apollo mission.
Any laser powerful enough to melt rocks with be powerful enough to melt the laser apparatus that is creating it, unless we find a way to prevent this.
As far as math involved, we would have to be able to calculate the exact distance, location, and velocity of the moon so that we can calculate the correct angle at which to fire the laser.
If the image (when viewed from Earth) is to look correctly, it has to appear as if it were painted on a flat surface. However, the moon is spherical. This would mean that we would have to calculate how to project the image in a way that would counteract the distortion of the moon. The act of projecting the laser actually does some of the math for us. By making the image look correct from Earth, it would look horrendously distorted from lunar orbit.