I find lots of answers on this question but not one that works when using .gif images and not markers. To use .gif images (and also animated gifs) I use code (which works)<
Another way to do it is to use Custom Overlay.
.
.
var overlay = new google.maps.OverlayView();
overlay.draw = function() {
this.getPanes().markerLayer.id = 'markerLayer';
}
overlay.setMap(map);
.
.
var deg = 270;
document.querySelector("#markerLayer img").style.transform = 'rotate(' + deg + 'deg)';
.
See this demo pen for more clarity.