The Xbox One is capable of installing games when in sleep mode into its internal storage. However, is it able to do so with external ones as well? Do I have to keep the console on the whole time to install into an external hard disk?
Yes, your Xbox One can install both digital and physical copies of games while in Sleep mode. I have done this myself enough times to verify it, but here is an additional source.
Likewise, the console is able to install either to internal storage or external drives while in sleep mode. It will attempt the install to the drive with most free space.