Reboot into recovery mode. Hold the Power button until the restart option pops up. Then, once it shows a black screen, press 'Volume UP + HOME + Power' at the same time.

Apply update with ADB. Once booted into LineageOS recovery mode, press:
Apply Update.

Apply from ADB.

Connect your phone to your computer with a cable.
On your computer, open a terminal application (PowerShell [Windows] or Bash [Linux]) in the directory where the Magisk APK file is located.
Type
adb sideload Magisk-v27.0.apk
.

On your phone, LineageOS recovery will display "Signature verification failed. Install anyway," which simply means LineageOS does not officially recognize that software. Hit 'Yes'.

The installation will indicate when it has finished. Once it does finish, please go back to the main settings and press 'Reboot system now'.
Once your phone has rebooted, you will see a Magisk app on your home screen. When pressing on the app, it will ask you to download it. Allow it to download.

Once downloaded, it will ask you to go through 'Additional Setup'. Press 'OK'.

Your phone has now been rooted. To verify if it is rooted, there are two simple options:
Open any app that can ask for root privileges: In a terminal, typing
su root
or
su
will ask the system if it can grant itself root access.

Install a Root Verification app such as
Root Verifier.