Being hit by lightning on a yacht is, just as it is on land, a fairly unusual and improbable event. That said, it can happen and so all risks should be mitigated.
The most important consideration is one of proper ‘earthing’. If you have a metal mast it’s likely that this will be hit first. Indeed, it’s usually expected that a mast will act as a shield for everything below, in a cone, on a radius 45 degrees down from the masthead. However, this assumes that the mast is properly earthed as are all other metallic parts of the vessel.
It is usual for the mast and other metal to be earthed via the engine and propellor shaft. If a mast is not properly earthed a lightning strike might well cause the electrical potential difference to simply blow a hole in the deck or the hull in order to ‘run to ground’ in the surrounding water. Obviously, this is not good.
If your boat is properly earthed then the most likely damage you should expect will be to electrical systems including your GPS, Chart Plotter, radios, telephones, radar, alarms and things like starter motors, etc. It’s possible that fire might be triggered by this event, so check all wiring and make a thorough check of the rig and hull structure as soon as it’s safe.
If you carry a handheld GPS, sat phone and other handheld kit (like a smart phone) it’s worth protecting them from a strike. To do this either put the items in the oven (which is, effectively, a Faraday Cage). Of course, if someone decides to warm the oven for lunch this can be unfortunate! You may therefore decide to put such items in a biscuit tin - which should serve the same purpose.
For this reason, if for no other, keeping an up-to-date set of paper charts on board is prudent, especially for cruisers and travellers. It’s also worth keeping a sextant on board and a reliable (and protected time piece set to UTC) but, of course, you need to know how to use it and carry the reduction tables too. Certainly, a handheld sat phone and a VHF and handheld GPS in your biscuit tin might well save you a great deal of grief!
Last, prevention is better than cure. Try to avoid thunderstorms! And tropical squalls with towering clouds above them. These are areas prone to lightning strikes. Keep most crew below decks and away from danger (although the mast should protect you in theory) and it’s probably not a great idea to hang onto rigging or go for a mast climb during a thunderstorm!