Is there a safe or better way of using an AAA battery in place of an AA battery in small electronic devices/ sensors, when in bind like pandemic?
It would be somewhat ugly, but I would say tape to bulk the battery up to the correct width, so that the holders / enclosures keep it in place. 
For the length, I would use a generic 6mm nut 


Its 5.2mm long which makes up for the length difference in most
cases, while having enough width to not move too much, and will make
reliable contact with a number of AA holders.
I am assuming you would place this on the negative side between the battery and the spring