In the US, yes you may carry them inside or outside the flashlight (with terminals protected, such as in a storage case). Here's the FAA info page on this topic:
https://www.faa.gov/about/initiatives/hazmat_safety/more_info/?hazmat=7
My understanding is they may also be checked if they are inside the device they are intended to power, so you should be able to put the flashlight with batteries inside in a checked bag.
TSA regulations add additional restrictions over FAA regulations for carry-ons. Although TSA allows flashlights in general, they do not allow "tools" longer than 7 inches and have specific restrictions on other items that might be usable as a "bludgeon." Last year there were also temporary restrictions on laptops on flights from some countries to the US, so there is precedent for limiting devices they might think could be used for hiding explosives.
Basically, they may have some discretion on large flashlights. If questioned, be polite, patient, and willing to turn a device on (to a sane level...don't blind them) to help yourself through security with minimal hassle.
https://www.tsa.gov/travel/security-screening/whatcanibring/all-list