You'll need to include event handlers for at least mouse press and mouse drag events on your canvas or imageview (depending on your strategy).
For the mouse press event, you'll want to store the x,y for the "starting corner" somewhere.
Then for the mouse drag event, you'll want to draw the rectangle from the startx,startY to the current mouseX,mouseY.
How you draw the rectangle depends on your strategy -- do you want to use a canvas, in which case you use the drawRect method of the GraphicsContext? Or do you want to create a javafx rectangle node which is added to the scene and appears on top of your imageview, and then modify the width/height of that rectangle whenever the mouse is dragged?