I don't know a great way to do this, the closest I've ever been able to get is to use a combination of specific plot
set-ups and note
widgets. As an example, start out with a plot called "Legend" with this setup to start:

Now size it to look something like this:

Now make a procedure to 'draw' legend guides (some detail in comments):
to setup-legend-plot
; Choose correct plot
set-current-plot "Legend"
clear-plot
; Define starting y and color
let starts [ [ 10 green ] [ 7 red ] [ 4 blue ] ]
; for each value in starts
foreach starts [ start ->
; make a range of values starting at the initial
; y value from 'starts'
let s first start
let f s - 2.5
let ran ( range s f -0.01 )
create-temporary-plot-pen "temp"
set-plot-pen-color last start
; draw lines at each y value to make it
; look like a solid drawing
foreach ran [ y ->
plot-pen-up
plotxy 1 y
plot-pen-down
plotxy 2 y
]
]
end
Calling setup-legend-plot
should now make your "Legend" plot look like

Now you can make some note
widgets and layer them over the blank space in the plot:


Not exactly straightforward, but definitely the closest I've found.
Edit:
"Closest I've found for building a legend within NetLogo." Javier's answer is a far better approach if you can swing it.