Here is Apple’s definitive compatibility list for Apple Pencil and iPad:
Apple Pencil compatibility - Apple Support
An iPad 5 doesn't support Apple Pencil at all.
In more detail...
Apple has four different versions of the Apple Pencil - these being the first and second generation Pencil, the USB-C Pencil, and the new Apple Pencil Pro. All have different capabilities and charging/pairing interfaces - and can only be used with models for which they were designed.
All models of iPad that (a) feature a Lightning connector and (b) actually support Apple Pencil, only support the first Generation Pencil. The first generation Pencil can also be used with an iPad10 - but requires a special adapter for pairing/charging with the host iPad.
All iPad models that have a USB-C port - and have been updated to iPadOS 17.1 or later - support the USB-C Pencil.
A second generation Pencil can only be used iPad models that have an inductive charging dock specifically designed for the Pencil. This Pencil docks magnetically with the host iPad.
The new Apple Pencil Pro is very similar to the second generation Pencil, but is only compatible with the new 2024 iPads Pro M4 and Air M2.
Hopefully this information will disambiguate the various models of Apple Pencil and their relative compatibility with iPad.