To tune in just intonation, stop tuning your guitar to a tuner! Tune one string by ear to a pitch reference and then tune the other strings by ear to each other. To tune two strings to a just fourth, play the seventh-fret harmonic of the higher string against the open lower string (or its twelfth- or fifth-fret harmonic). For example, once you've tuned your A string to a tuning fork, find your E by playing the seventh-fret harmonic of the A string. This will put the E string's frequency at ¾ of the A string's frequency, a just perfect fourth.
If you're tuning strings a fifth apart, for example if you're tuning the lowest string to D, reverse the procedure: play the seventh-fret harmonic of the lower string against the open higher string (or its twelfth- or fifth-fret harmonic).
The interval between G and B, of course, is a major third, and a just major third is a 5:4 ratio. But if you use 5:4 for the major third and 4:3 for the fourths, you will find that your highest string is not 2 octaves above the lowest, a factor of 4:1, but rather (4:3)⁴ × 5:4, which is 320:81 or about 3.95:1. If you tune the high E string to the low one, or to the seventh-fret harmonic of the A string, and then tune the B string to the E string, then the major third will have a ratio of 81:64 instead of 5:4.
I have a Peterson tuner which has a Just Intonation setting. It can be set to keys, however, it still doesn't seem to work. Theoretically, if I tune the guitar to open D, I'd have to set the key to D. Or do I have to use A 440 as reference and tune the strings use A as the key?
This is probably not working because the tuner is giving you the most common just diatonic scale for the key you're selecting. This scale has the ratios 1:1, 9:8, 5:4, 4:3, 3:2, 5:3, 15:8, 2:1. Note that the perfect fifth between 9:8 and 5:3 -- the second and sixth degrees of the scale -- is 40:27 instead of 3:2. If you invert that, you get a perfect fourth of 27:20 instead of 4:3.
In the key of D, that "unjust" interval is between E and B. In A, it's between B and F♯. It looks like choosing D is therefore probably better for open D tuning and A for standard tuning.
But there's another issue, that of the minor seventh. In other words, in the key of A, where does the tuner put G? There are three possibilities for the minor seventh: 16:9 (two 4:3 fourths), 9:5 (a 3:2 fifth and a 6:5 minor third) and 7:4 (the acoustically pure seventh from the harmonic series). In the first case, the ratio between D and G will be 4:3, as expected, but the other two ratios are the more commonly used, so choosing A for standard tuning is more likely to give you an out-of-tune interval there. In the case of 9:5, it will be 9:5 ÷ 4:3 or 27:20, whereas for 7:4 the ratio will be 7:4 ÷ 4:3 or 21:16.
In conclusion, the most common arrangements of the just diatonic scale have three consecutive 3:2 fifths (in circle-of-fifths order). Using D major as our example, they are G-D-A-E. Other perfect fifths are out of tune so the scale can contain some 5:4 major thirds. The pitches used in standard guitar tuning span four consecutive spots on the circle of fifths, G-D-A-E-B, so it's not possible to pick a key in which the most common just-intonation scales will have all of the fourths at a 4:3 ratio.
As a postscript, there are two related issues that are somewhat beyond the scope of this answer, which is long enough, but that deserve to be mentioned.
The first is the question of the absolute pitch you're tuning to. If you set your tuner to just intonation in D, does it keep A at 440 Hz, giving D a frequency of 293 ⅓ Hz, it does it build the scale on the equal-tempered frequency of 440 ÷ 2(7⁄12) or approximately 293.6648 Hz? It probably doesn't matter much, certainly not if you're playing by yourself.
The second question is that of the 81:64 major third between the G and B strings. This will be out of tune with the fourth-fret harmonic of the G string. (If your A is 110 Hz, G will be 195 5⁄9 Hz and open B will be 247.5 Hz, so the fourth-fret harmonic of G will be 977 7⁄9 Hz while the fifth-fret harmonic of B will be 990 Hz.) If this is a problem for you then you will need to decide which compromises you can make depending on your needs. If you want to explore that, it's probably better to ask a new question.