Open up your image. Go to Layer >> Duplicate Layer. Now, go to Image >> Canvas Size and expand the image by 2 pixels (on both width and height). Make sure the layer is not a locked background. If it is, double click on the layer in the layers window.
On the first layer (NOT the copy), go to Edit >> Stroke. Match your settings:

Right click on the same layer (in the Layers window). If the Layers window is not open, go to Window and make sure Layers is checked.
Save this pattern to your computer:

Go to Edit >> Define Pattern.
In Blending Options, check off Pattern Overlay. Use the pattern you just made.

Your image should now have a dotted border!