No, there is nothing you can do. Nikon's AF-P lenses do not work with the D5100. At the time of release of the first AF-P lenses (the 18–55mm, both with and without VR), the only cameras that supported AF-P lenses were D5300 and D5500, and a firmware update was made available to the D3300 so it would support AF-P lenses as well.
See this article at Nikonrumors.com: The new AF-P Nikkor 18–55mm f/3.5–5.6G DX lenses works only with three Nikon DSLR cameras
There has been no firmware update for the D5100 to support this lens.
Nikon's sites for the AF-P DX NIKKOR 18–55mm f/3.5–5.6G (both with and without VR), and the AF-P DX NIKKOR 70–300mm f/4.5–6.3G ED (also both with and without VR) make the following statements with respect to AF-P and autofocus with these lenses:
* Because AF-P lenses incorporate a stepping motor, the number of compatible cameras is limited. Even for compatible cameras, firmware update may be required.
* Because focus mode (AF/MF) is set using the camera menus, the number of compatible cameras is limited.
Note that these statements are not present on their page for the AF-P DX NIKKOR 10–20mm f/4.5–5.6G VR lens.
In the User Manuals for the AF-P 18–55mm and AF-P 70–300mm lenses, Nikon states:
This lens does not support D4-series, D3-series, D2-series, D1-series, D800- series, D700, D610, D600, D300-series, D200, D100, D90, D80, D70-series, D60, D50, D40-series, D7000, D5100, D5000, D3200, D3100 or D3000 digital SLR cameras or film SLR cameras. When using it with a D5500, D5300, or D3300, be sure the camera firmware has been updated to the latest version.
Ok... it's easier to state what bodies the lenses do support. Citing Thom Hogan's article at dslrbodies.com regarding the AF-P 70–300mm lenses,
So here’s my conclusion:
- D3400/D5500 users: this is the basic telephoto zoom to buy, no questions asked
- D500, D3300, D5200, D5300 users: make sure you have the current firmware; probably the basic telephoto lens to buy
- D7100, D7200 users: note that you can’t set VR to off; if that’s okay with you, consider the lens
- All other older DX users: do not buy this lens