If you're going somewhere more remote, carrying a gun might make sense. Reach out to the Alaska Department of Public Safety (who issue concealed carry permits to US Citizens) to ask about the relevant laws. (https://dps.alaska.gov/) I'd also reach out to the nearest Forest Service station to where you're going, and ask whether carrying is actually a good idea.
For the record, it probably is not a good idea. Bears in many parts of Alaska are famously conditioned to run toward gunshots— chalk it up to generations of hunters killing animals and abandoning the carcass when a bear shows up. From what the Alaskan hunters and outdoorsmen I met there told me, the further north (toward the interior of Alaska) you go, the more conditioned bears are to move toward gunfire. Hiking with a gun is perfectly safe until you fire it, at which point everything with claws within earshot (and, there may be more than one such thing) comes toward you.
The better solution is usually to make noise while you hike so you don't startle any animals you come across. In the Denali area, most hikers wear bells on their packs. Moose are a bigger danger than bears there, and there are enough people around in the summer that you'll get some uncomfortable looks if you have a rifle slung around your back.
Speaking of Denali, specific rules apply to national parks. Since 2010, it's been legal at least for US citizens to carry guns in national parks, but nobody is allowed to bring a gun to any US government buildings in National Parks... which, e.g., if you're in Denali, is every building you might need to enter for supplies, information, etc. This might pose logistical challenges. And, not that you're expected to die without defending yourself, but wildlife in national parks are protected, meaning you end up in a legal bind even if you shot in self-defense. It might make sense to just do what everybody else does.
For what it's worth, I'm not saying this because I'm an anti-gun person. My family carries in the backcountry in Idaho and Montana, where the threats are cougars or wolves. The difference is that those respond to gunfire in the expected way... by running for it.