Area of an octagon is A~.828S2. S is the span, the dimensions from flat to flat.
Use that formula to find the area of an octagon, multiply by the length of the barrel, then subtract the volume of the bore (Pi times bore/2 squared x length of the bore). That will give you the volume of the barrel (ignoring stuff like the rifling and the metal machined away to make the breechplug threads. Then use multiply that figure by the weight of steel by volume (I've found a couple different figures online).
For finding the weight of a swamped barrel, you have take the areas of key points down the barrel (key points being where the rate of taper changes), figure out the radii of circles with the same area, and then use that radii to calculate the volume of a series of truncated cones. Add the volume of those cones together and subtract the volume of the bore, and then calculate the mass as above. Complicated, but once you've done it a couple times it gets easier. Depending on the exact sequence of the calculations you can start with the dimensions of an original barrel and fiddle around with different calibers, keeping the weight the same or reducing it by a given percentage throughout, all kinds of things. The first time I did it I was trying to scale a barrel with a 1.20 breech and a .60 bore down to .50 caliber and a 1.125 breech (D weight) - I found that keeping the barrel the same weight resulted in a breech about 1.14, IIRC, so I just reduced the rest of the barrel wall areas by the appropriate percentage and then work backwards to figure out what the span should be.
Harder to explain than to do, though I always make a chart so I can keep my figures straight.