As regular user of a second generation Apple Pencil with a fifth generation iPad Pro, I have not encountered the behaviour that you describe. The Pencil has worked without issue with iPadOS 27/27.0.1 and prior versions of iPadOS.
Similarly, if this were a widespread issue, the Apple Support Community would be awash with complaint. While Pencil's can and do fail for a variety of reasons, the issue that you describe is not endemic. Either your specific Pencil, or perhaps your iPad, may have an issue.
It is generally recommended that a second generation Apple Pencil (and Apple Pencil Pro) should be kept docked with the iPad when not in active use - as this ensures that the tiny internal battery is kept optimally charged when not in use. Charging only occur when the battery requires charge from the iPad, optimal charge being entirely automatic.
Keeping the Pencil separated from the iPad when unused risks allowing its battery to discharge; if allowed to remain in this state, the battery will suffer irreparable damage. When the battery fails, the only remedy is to replace the entire Pencil; the battery is not a serviceable item.
An otherwise healthy Apple Pencil will suffer no negative consequences from being docked with its host iPad for extended periods.
Charge your Apple Pencil and check the battery - Apple Support
So as to isolate the issue, you might try using your Pencil with another compatible iPad. If the problem is consistent, the Pencil itself has a fault.
Likewise, for testing purposes, try substituting your Pencil for another known-good example - and test with your iPad. If the problem clears, then your Pencil has fault. If the problem is consistent, then the iPad has a problem that will require further troubleshooting...
Always begin with a forced restart of the iPad - as this will often clear an isolated software issue:
Force restart iPad - Apple Support
If the problem persists, it may be necessary to reset your iPad settings. While this reset will not cause any loss of data, as a precaution, it is always wise to ensure that you have a current iCloud or iTunes backup before performing the reset:
How to back up your iPhone, iPad, and iPod touch - Apple Support
When you are happy to proceed, you can perform the reset from iPad settings:
Settings > General > Transfer or Reset iPad > Reset > Reset All Settings
If the problem still doesn’t clear, the next step is to reset the iPad to factory settings:
Restore your iPhone, iPad, or iPod to factory settings - Apple Support
Otherwise, you would be best advised to seek assistance directly from Apple Support. You can contact the Support Team using the Support link at top-right or bottom-left of this page. Alternatively you can initiate and manage your support cases using the excellent Apple Support App. If not already installed on your iPad, the App can be downloaded from the App Store:
https://apps.apple.com/app/apple-support/id1130498044
You might instead visit the Genius Bar at your local Apple Store or Apple Authorised Service Provider (AASP) - where the technicians will be able to hands-on test and assess your iPad and Pencil. Here, for testing purposes, it should be possible to substitute your Pencil - and pursue additional troubleshooting. Making an appointment prior to your visit is advised - as this will ensure that the technician will be able to spend the time required to investigate the problem:
Genius Bar Reservation and Apple Support Options - Apple