The secret sauce is that you can ask legend_label to use the LaTeX representation of the function like so:
p1=plot(y1, (t,-5,5), gridlines=True,color='red', legend_label='$'+latex(y1)+'$')