Photoshop CS6 makes it easy.
With Photoshop CS5.5 and older, the best way is to make a path in the shape you want, then stroke it with a brush that's been prepared with the proper spacing and direction dynamics to cause the stroke to be dotted or dashed.
Generally speaking you can find a lot of tutorials for doing it via Google. What I might do is to search for something along the lines of dashed stroke photoshop, possibly also adding the word tutorial in the mix, then use the Google Images search, find one that looks like what you're trying to accomplish, and click through the Website For This Image link.
Here's one of the first I ran across with such a search: http://www.techimo.com/forum/graphic-design-digital-photography/110702-mini-tutorial-photoshop-making-dotted-dashed-lines-complex-path.html
-Noel