I have both an iMac and a MacBook Pro. When I want to upgrade to macOS Mojave, do I have to download the installer in both machines? Or is it possible to copy it over to the other device and use the same installer?
Yes. You can copy the installer to the other machine as it's "universal" to the Mac platform.
However, my suggestion would be to create a USB Installer instead. This way you can download it, "move" it to the USB and then remove it from your installation.
You will need an 8GB USB flash, formatted with a GUID partition and HFS+. Then execute the following command:
sudo /Applications/Install\ macOS\ Mojave\ Beta.app/Contents/Resources/createinstallmedia --volume /Volumes/USB\ Installer --nointeraction --downloadassets
/Volumes/USB\ Installer is the name of the USB flash drive you've inserted.
Assuming that your model of iMac and MacBook Pro is compatible (as mentioned in the list below), you can use a single installer downloaded from the Mac App Store to install macOS Mojave on both of them.
macOS Mojave 10.14 will be publicly released on 24th September 2018 (as announced in the Apple Special Event, September 2018 on 12th September). You will be able to download the installer from MacApp Store.
This installer can be copied over and used to install macOS Mojave on any supported Apple Mac. You can install macOS Mojave on any of these supported Macs:
MacBook models introduced in early 2015 or later
MacBook Air models introduced in mid 2012 or later
MacBook Pro models introduced in mid 2012 or later
Mac mini models introduced in late 2012 or later
iMac models introduced in late 2012 or later
iMac Pro (all models)
Mac Pro models introduced in late 2013, plus mid 2010 or mid 2012 models with recommended Metal-capable graphics processor, including MSI Gaming Radeon RX 560 and Sapphire Radeon PULSE RX 580
Additional compatibility and support information can be obtained from the Apple support page, Get ready for macOS Mojave