I've done it using a heat tape and then covered with regular foam pipe insulation. The foam insulation with taped joints and seams may be enough cause usually it is the direct contact with cold air that causes a place to freeze. The tape should help keep it from freezing especially if you are in Alaska or Buffalo. Some heat tapes aren't made to be covered with insulation but some are. The trick is putting in a plugin for the tape. Also most tapes have a light to show they are working and it is nice to have that light located where you can check it. For other inquiring minds, Pex when the water freezes will expand and not break or crack like other plumbing but once it freezes, you may have to heat your attic or wait on a warm spell to get the water thawed and flowing.