It wasn't the battery, and this pen doesn't pair via Bluetooth. With help from Dell support, I found the solution, which was to install the latest Intel and NVIDIA graphics drivers.
I have an Inspiron 7620 2-in-1 and the recommended active pen PN5122W. It works for a few minutes after restarting the laptop, then just stops being detected by the screen. The battery in the pen is brand new and I have tested it and confirmed the battery has full power. I have looked at Dell Peripheral Manager but it does not have any option to manage a pen available (despite what the user-guide says). I have tried an alternative Dell pen that I normally use on another Dell laptop, and it does the same: it is detected by the 7620 for a few minutes, then stops until the laptop is rebooted. After the pen stops working on the 7620, I am still able to use it with my other Dell laptop with no problems (Latitude 7400). This suggests to me that the problem is very clearly on the laptop, not the pen. Unless I can get this working more reliably, I will have to return the pen as it's useless like this.
Inspiron 7620 and Pen PN5122W stop working