Exactly. Even if the phone is already unlocked, the official LinageOS installation instructions explicitly say to do a "Format Data / Factory Reset" in recovery before sideloading the OS.
However if you're flashing a ROM or upgrading an already unlocked phone you do not need to format it.