I would not recommend using improvised lock nuts in any life safety application. However, there are times when a nut may vibrate loose but you are in a position where you can’t get to the store.
The solenoid I installed while Converting a generator to electric start was just such a problem. I needed to finish before the wife got home and could not waste another hour in a round trip to the store.
Additionally, I couldn’t have any more hardware store charges on the debit card that day. I was already dipping into the joint account for YouTube projects that did not have prior spousal approval.
What I did was tighten down nuts mounting the solenoid. Next I wrapped a couple turns of teflon tape to the bolt. Then I screwed another nut over the tape.
The teflon tape acts like the nylon ring inside of a real lock nut. Having two nuts also helps with reducing loosening from vibration.
Yes, it is an improvised solution. No it it not as good as a store-bought solution. However, it does work, and I am pleased with it for this use. Especially as my wife is happy the generator can now be started without a lot of struggle.