My guess is no. You want the img (or the div container) to be a block element. At the same time, you want the image to act like an inline element -- adjusting to the display.
A block element by definition cannot switch order with other elements depending on the display. In other words, you have to change the semantics to get what you want. But you still are not changing the order of elements.
One thought is that you could use CSS media queries to conditionally change the img or div elements from block display to inline display depending on the device's screen dimensions. That might help if you could boil your use cases to maybe two or three display sizes.
I am not a css expert, so I'd love to hear if there is a way that works. But my guess is currently no, and even if a method exists, it probably won't be supported on Kindles anytime soon.
I don't know much about Latex, but it can perform these conditional tricks because you are dealing with a fixed display size. With ebooks you are dealing with an endless variety of display sizes and devices.
UPDATE: I'm having second thoughts about the answer. CSS has some new mechanisms like flexbox and grid formatting to deal with these cases. I could easily see a time in the next 5 years where ebook readers can deal with positioning of an image on a fixed point in the page. Jimmy Panoz pointed out that because reading systems use browser rendering systems, eventually reading systems will allow you to use CSS Feature Queries to try CSS experimental features.