The closest you'll get (easily) is on a stroke....

But... as you can see the angle is always 45° and always in the lower left. Even adjusting gradient stops won't change that....

(Note the 90° angle in the above created by color stops.)
You can then rotate the object so the angle hits the upper right corner.... but you can't really move it from that corner and retain any sort of angle in the gradient.
So, the best you can do is use a shape rather than a stroke, and configure a Gradient Mesh on that shape...

Then apply a clipping mask to the mesh object if necessary.
Mesh with clipping mask...

Nowhere near as editable or easy to apply.
Don't yell at me.... Adobe should address stuff like this. It's mind-boggling why Illustrator doesn't have conical or angled gradients in 2018.
These screenshots are from AICS6, but CC2018 offers no additional improvements in this area. (tested and confirmed)