I am not sure if this beam is decorative or structural
But you can see the rotten area in red rectangle
What is the best way to fix something like this?
The rafter is kind of structural, but it is hardly holding up anything. It can be cut on to a degree and still keep the rake board from sagging. The load that is in that end of the 4X6 may not be no more than a few hundred pounds over the whole length. The 1X4 spaced sheathing would a lot of the weight, but the roof would still sag, so the cantilevered beam keeps everything in line.
The one thing I see that helped advance the rot was the extension of the beam past the rafter, the more extension, the more water sets to advance rot. My first move would be to reduce, but not eliminate a major part of the extension, leaving about a 1/2". This will minimze the flat shelf that will harbor a lot of moisture, including dew. This should be done on all beams around the house, double prime and double paint for protection, and add a flashing cap for best protection, then the extension does not matter, just the fasteners needed to hold the rafter in place. Secondly that cutting will expose the condition of the rafter that the paint is hiding, and how far along the rot is. With that much done, I would cut an angle off the top of the beam to remove all if at least most of the rot and replace the triangular cut with new material prime all around, and prime the cut of the original beam too, and use a wood treatment on any remaining rot that may not have been removed by the cutting.
You could replace the wood with pressure treated material ut that will not hold paint until all the surface treatment leached out for about 6 months so the paint will stick.
With the angle depicted, the wedge will only need a few fasteners to keep it from sliding back out, otherwise, gravity and pressure from the rafter above would keep it in place due to the long angle of the cut.