Rarely is it the dynamo.
The dash light is telling you the system is not charging hence the dead battery.
Forum member lugbolt posted his personal charging system diagnosis procedure which is very comprehensive and I will add it to my post:
the books are jinglish, and IMO hard to follow.
thus I have my own tests
the regulator/rectifier has 6 wires. 2 are the same color, they end up at the dynamo. AC. One is a black ground wire. You will also have a +12v from the slow-blow fuse, and a +12v ignition (key on) and then a wire that runs to a charge lamp (if applicable, but it'll still have that wire).
Typically loss of charging performance is fairly easy to diagnose if you have the know-how, and a digital volt-ohm meter that has any quality whatsoever. A $10 one isn't that, just something else to throw into file 13 when it reads wrong.
The two dynamo wires (usually sky blue) are AC voltage, as said. Start engine, disconnect regulator and test ac output at the regulator connector, between the two dynamo wires. Should be 24V+ and I like to see more than 45 or so at full throttle. If it charges anything it's probably ok, they are a foolproof and extremely simple design that rarely fails outside of seized bearings. OK? Move on. Check your ground at the reg connector. One probe of the DVOM (set to ohms) on the ground pin in the connector and the other pin on a good ground, frame, transmission, etc. Must be clean. If you have more than a few ohms of resistance, your ground or harness is suspect
onward. Find your wire that comes from the battery. Backprobe the regulator connector. Now put your DVOM on DC volts. One probe goes to your connector, the other goes to the battery +. Should be under 500mv, or 0.500v. Ok? Move on. More than 0.5v? You have either a harness problem or a bad connection at the fuse, or whatever.
Last wire that will affect charging is what I call the "trigger" wire...it turns the reguator "on" so to speak, via the key switch. That one gets 12v when the key is on. Same as the last test, backprobe the connector with the key on. One probe of the DVOM in the connector and the other to the + battery terminal (use the post not the cable). You want to see less than 0.5v on the meter. If you see more than that, harness, fuse block, keyswitch, etc. Follow your wiring diagram. If you do see less than 0.5v, that circuit is not suspect, and there's a possibity you have a bad regulator.
Ideally you want to test everything AROUND the regulator because testing the reg itself isn't always conclusive. Thus, once you know you have AC voltage from the dynamo, you have good ground, you have +12v from the batt and ignition switch, the only component left is the reg. Process of elimination.
Electrical diag is not all that hard or it can be. It's all what you make of it. Don't put too much thought into it because it'll bite you. It's simple for the most part
speaking of being bit, be careful around the dynamo wires when testing. There's a little bit of voltage there and it's ac voltage, so it can bite you.
If you have questions arising from trying to use the above do not hesitate to ask.
Dave