The second generation Apple Pencil should be kept docked with the iPad when not in use - as this ensures that the tiny internal battery is kept healthily charged when not in use. Likewise, a first generation Apple Pencil must be regularly charged to avoid unrecoverable failure of the Pencil battery.
As described, your Apple Pencil is displaying symptoms of a dead battery - that will not accept or hold any charge.
For a first generation Pencil, assuming that you do not have any other iPad charging issues - and that the Lightning Port of your iPad is free from debris - whilst the Pencil is plugged-in to the Lightning Port of your iPad, verify that the Pencil is recognised:
Settings > General > About
Scroll to the bottom of the page - and you should find two identical entries for the Pencil (one each for the physical and Bluetooth connections). If you see both entries, the Pencil in paired and the electronics are most likely good. Check the Battery Widget from your first Home Page for Pencil charging status.
The verification process is similar for the second generation Pencil - although you will see only the one entry within Settings/About. The battery charging status can be similarly verified from the Battery Widget.
The tiny internal Li-ion battery within the Pencil 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 the Pencil Battery has failed, the only remedy is to replace the Pencil. If purchased directly from Apple, if the battery has failed and your pencil is within its one-year warranty, you should look to having it replaced. If no physical damage is evident, Apple usually replace the Pencil without quibble.
If the issue is not satisfactorily identified using the above guidance, this troubleshooting guide may be helpful:
https://appletoolbox.com/apple-pencil-not-working-heres-our-troubleshooting-guide/
I hope this information proves to be helpful in both diagnosing and resolving the problem.