safely locked to the frame, and I can simply leave it there.
Summary
To answer your question about the existence of locking bags - they are out there. As an example (not a recommendation) Ortlieb makes a handlebar mount and bags that can be locked to the mount. No locking bag system is secure.
Best Option
A handlebar bag with a quick release mount enabling you to take your bag with you is the safest option.
Here is an example of mounting hardware for a locking bag

Here it is installed
The handlebar mount clamps to the handlebar with a steel cable (mount instructions). The bag slides into the mount and then the lid and bag are locked to the mount (bag instructions).
One of several bags Ortlieb makes that works with this mounting system is the "Ultimate Six"
Ortlieb says that their handlebar mount is compatible with any bag that uses the "Rixen&Kaul KLICKfix" system. Googling "klickfix" will bring up a variety of products. This is just one system as an example.
But....
As everyone has pointed out, leaving something on the bike - even if locked to the bike - is not safe. A cloth bag can be cut open.
Echoing the recommendation of the other answers...
A handle bar bag or pannier (or other bag type) with a quick release mount so you could easily take the bag with you is the safest option and it's often less expensive than bags with locks.
Recommendation
Use a handlebar bag that has a quick release system so you can easily take the bag with you. Searching "quick release bicycle handlebar bag" on Amazon brings up a variety of options.
Things to keep in mind
Panniers usually require the installation of a rack on the back of the bike. A quick release handlebar bag usually requires the installation of some type of mount on the handlebar. It's nice when the bag comes with the mount - Ortlieb bags do not come with the mount.
With a handlebar bag it's important to keep weight below 5 kg because too much weight on the handlebar can affect steering. Panniers can handle more weight with less effect on handling.