Yes, you can. The display port is bi-directional. In a sort of quirky way. Apple has addressed one of the longest lingering questions of the iMac line (and basically all AIO lines). People upgrade the PC but could reuse the display. With an AIO everything had to go.
The one problem, at least environmentally, is that you can't use the display without also having the entire "computer" part running. This means you're consuming XX extra watts the entire time.
I'm not sure of this, but I assume the default behavior would be putting the imac itself to sleep when it was connected to an external video source. This would use a bit more power than a simple display, but not much.