Clearly, your Pencil is successfully pairing with your iPad. As such, you can safely exclude all thoughts of your Pencil being incompatible with your model of iPad, or any issues related to pairing and/or Bluetooth communication with the iPad.
You own troubleshooting has narrowed the cause to your Pencil as the source of difficulty - most likely an issue with the Pencil transducer that interacts with the iPad screen hardware.
Ensure that the replaceable plastic pencil tip is screwed firmly (i.e., finger tight) into the body of the Apple Pencil; even a slightly loosened tip will cause issues. When correctly positioned, there should be a tiny gap (around the full circumference - of about the thickness of a sheet of paper) between the tip and the body of the Pencil.
If the Pencil still fails to register, the metal transducer beneath the tip may have been damaged - perhaps due to a fall, impact, or excessive pressure to the pencil tip. The transducer element is relatively fragile - and if damaged, may provide inconsistent performance, if it works at all. If the transducer has suffered any damage at all, the only remedy is replacement of the Pencil.
Substitution with another Pencil, as you have already done, will definitively confirm or exclude a positive diagnosis.