You are asking to achieve effects that the software wasn't designed to perform.
Ultimately you may be best served in that regard by raising an issue on ggplot2 github site, asking for the features you desire to be implemented by the developers.
As a second best, although you can not use ggsave, you can save and restore any such chart by use of recordPlot() and save/load functions. also although you can't rotate the full legend, you can rotate their text elements.
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.1.2
library(grid)
rotation <- 45
(p <- ggplot(mtcars, aes(mpg, color = factor(cyl))) +
geom_density() + theme(legend.text = element_text(angle=(-1*rotation)),
text = element_text(angle=(-1*rotation)),
axis.text = element_text(angle=(-1*rotation)),
axis.title = element_text(angle=(-1*rotation)),
axis.title.y = element_text(angle=(-1*rotation))))
grid.newpage()
pushViewport(viewport(name = "rotate", angle = rotation, width = 0.7, height = 0.7))
print(p, vp = "rotate", newpage = FALSE)
a1 <- recordPlot()
save(a1,file = "mysavedplot.Rdata")
you can restart your R session losing your objects, and restore the visual from disk :
on second thoughts it may be possible to combine an untransformed legend with a transformed plot, doing something like plotting and rotating (without the legend) and then layering over it a plot consisting of untransformed legend only, although I don't have all that much time to experiment with that today