Apply a strip of double-sided butyl tape along the edge of the roofing panels that meet the gable.
Set a piece of gable trim in place, hooked over the edge of the gable and covering the butyl tape. Drive a wood screw down through the top of the trim and into the side of it every 2 feet along its length to secure it in place.
Place the next piece of trim, overlapping the first by 4 inches. Screw it to the roof substrate and metal roofing panel just as you did the first one. Continue adding trim until the entire gable edge is covered.