It is possible to use classoption in the YAML header of a RMarkdown document, to adjust output to LaTeX.
Making global settings with classoption works fine for me, but I would for example like to use the aspectratio=43 classoption for only for beamer_presentation2 and not pdf_book output.
I tried to move the classoption below the document like in
Unfortunately, rmarkdown does not allow that. classoption is a Pandoc option and needs to be provided at top level. If you want to provide it at the output format level, it is not straighforward in rmarkdown but probably still possible by passing it as a Variable pandoc flag in pandoc_args argument.
FYI, new tool Quarto https://quarto.org (next generation of R Markdown) solves this problem, by allowing Pandoc's variables to be passed at format level.