I opted for a removable solution that is easily rigged, even if underway:


It uses a
commercial, battery powered set of dual navigation lights together with a base and a bungee cord. In the latest incarnation of this, the two "fingers" on the base are cut from a strip of aluminum and slip around the stem fitting (into the gap between deck and forestay). The other pieces, including the thicker part supporting the fingers are made plywood and dimensioned so the light rests on the rubrail. Everything's glued together and liberally coated with epoxy, then varnished for UV protection.
Not shown in the picture on the right is a stainless steel bolt that's epoxied in the middle of the base and onto which the light is screwed using the mounting threads that are part of the design of the nav light. The bungee goes around the forestay and hooks into the notch to secure the light.
If I'm heading out after dark (or late enough in the day that I'll expect to need lights) I rig this setup at the dock, but if I'm simply returning later than planned, I can also go forward and mount it while on the water (the DS is plenty stable enough for that).
The same brand sells an all-around white light, also battery operated. You can get it with a stand that inserts into a deck fitting. If you mount that in a corner at the stern, angled a bit aft, you should be fine while motoring. The boom is shorter than the deck, so anything mounted in the corner should be out of the way (and the raised light is needed only when motoring).
An off-center mount is permitted whenever there are reasons why a centerline mount is not practical. With the rudder / tiller occupying the center of the deck, I think that exception would qualify here.
Under sail, you need a stern light that's visible for the correct sector (135 degrees). I believe you can get one from the same brand, and would mount it on deck, pointing aft. (Simply, pointing the all-around light aft would give you the wrong sector, unless you make some kind of cap to block the other 225 degrees).
Alternatively, if you always go out with a 12V battery, you could get
a set of fixed LED navigation lights and install them at the front and rear, just below the rubrail. You'll need two switches, because the stern light needs to be off when motoring. Again, you'd need a light on a pole for that; they make those for small motor boats (the socket is wired to supply the electricity). Ideally, you'd get LED lights (to save on battery) but with or without that solution is going to be pricey.
Some of the removable
LED lights are really fancy with different light patterns and a magnetic base that you can mount on your boat and just clip the lights to. You'd need two, one dual red/green for the front and one for the stern that can be selected to do 135 or 360 degrees. (Technically you need to raise the 360 on a pole).
Whatever you do, you probably don't want to mount anything on your masthead.There are provisions in the regulations that allow for a "tricolor" masthead light, but quite apart from the difficulty of getting power to that location, the problem with those is that other vessels may very likely misestimate your position, because it's hard at night to account for the elevation of your light.