The OSC 1337 protocol pioneered by iTerm2 does exactly that. You'll have to check whether your preferred terminal supports it (I known mlterm does), either from documentation or just trying it¹.
Also, some terminals support the DEC SIXEL protocol² (again, I know mlterm does).
Edit: I couldn't find a simple SIXEL sample — you'd think one of the popular sixel libraries would have some in unit tests, but no. So for the purpose of this thread (but maybe not forever, hence /tmp/),
Those are such that output directly to the terminal will produce an image if that format is supported (and probably nothing if not, but I'm not making promises).
Also, some terminals support the DEC SIXEL protocol² (again, I know mlterm does).
¹ https://www.iterm2.com/utilities/imgcat
² https://en.wikipedia.org/wiki/Sixel
Edit: I couldn't find a simple SIXEL sample — you'd think one of the popular sixel libraries would have some in unit tests, but no. So for the purpose of this thread (but maybe not forever, hence /tmp/),
Those are such that output directly to the terminal will produce an image if that format is supported (and probably nothing if not, but I'm not making promises).