First, if you have not already updated your iPad to the most recent version of iPadOS, you should do so. iPadOS 14.7.1 is current.
This support page may be helpful with pairing and use of the Pencil with your iPad:
Connect Apple Pencil with your iPad - Apple Support
If you continue to experience difficulties, here is one of the better troubleshooting guides:
https://appletoolbox.com/apple-pencil-not-working-heres-our-troubleshooting-guide/
Assuming that you do not have any other iPad charging issues, whilst the Pencil is docked with the host iPad, verify that the Pencil is recognised:
Settings > General > About
Scroll to the bottom of the page - and you should find an entry for the Pencil. If present, the Pencil electronics are good. Whilst you are here, tap the entry and check the firmware version of your Pencil:
Check the Model Number and Firmware Version; 0154.0093.0444.0060 is current for the A2051 Pencil. More of this later.
Whilst docked with the iPad, verify the Pencil charging status from the Battery Widget - this being accessed from your first Home Screen or from iPad Settings. Your Pencil should show that it is charging - with an increasing battery charge percentage. If not, then perhaps you have a bad Pencil.
The tiny internal Li-ion battery is susceptible to permanent/irreversible damage through being left discharged for long periods. Even some “new” pencils can exhibit signs of failure out-of-the-box if they are “old stock”.
It is essential that if you have an Apple Pencil that you charge it regularly - whether used or not - so as to protect the battery from deep-discharge. Do not allow a pencil to remain in low-charge state for any period of time - as the internal battery will fail, rendering the Pencil useless.
If your Pencil does not have the current firmware version loaded - and is able to successfully pair and charge from the iPad - leave the Pencil docked with the iPad. Ensure that your iPad is connected to WiFi and your Power Adapter - and leave the iPad to charge undisturbed overnight. Your Pencil firmware should update whilst the iPad and Pencil are undisturbed overnight.