In the Legend widget's function onOpen(), I changed the Legend constructor to
this.legend = new Legend(legendParams, document.getElementById('legend'));
the 'legend' element is the name of the <div> in my custom widget, where I want the legend to appear.
This makes it so that when I open the Legend widget from the panel, the Legend items appear in my custom widget in the 'legend' div.
It works great, but I would like it to work without having to open the Legend widget from the panel.