Retaining bottle carbonation when filling from a pressure carbonated keg?

Is it possible to use a pressure carbonated keg to fill bottles with a beer gun or something similar and retain satisfactory carbonation and shelf life in the bottles?

yes, purge the bottle with co2 if possible and cap on foam. This is basically what breweries do. Their beer is always carbonated (or it should be).