In the interwar period carriers were often heavily armed; HMS Eagle had 9x6" guns, the USS Sara & Lex has 8 x 8" and the Kaga & Akagai had 10x7.9". However the only time such heavy guns would have been the slightest bit of use was when the Glorious was sunk by the guns of the S & off Norway in 1940, and even the American and Japanese 8" batteries wouldn't have helped much there.
But WI a naval war had broken out 10 years earlier, when planes were much more feeble? Could these guns have been worth the trouble? Would carriers have been used in a gun battle simply because their armament existed and was on the scene?