I tried to figure out just how accurately we are able to point stuff in space and found out the hubble telescope is able to "lock onto a target without deviating more than 7/1000th of an arcsecond, or about the width of a human hair seen at a distance of 1 mile." [1]
That's pretty amazing to me. Though I'm not sure if that would be enough, or whether we can be even more accurate.
With a laser beam it might also not be a problem if you're just slightly inaccurate, say only hitting your mark 70% of the time as long as you still manage to heat your target spot up sufficiently.
[1]: https://www.nasa.gov/mission_pages/hubble/story/index.html
Since people smarter than me have floated this as a way of deflecting asteroids, I assume there's some kind of way to focus it over those distances? It seems nontrivial though.