Hari this is probably not possible without additional backend code.
The code that renders the iframe only knows the information that's part of the URL, and I don't think shorts can be told apart from just their URL. The YouTube API would have to be used to retrieve the video ratio.
If you want to render all YouTube videos in a vertical iframe it might be easier, but it would still require creating a Flarum extension to modify the YouTube embed template.