It sounds like it might be best as a plugin using all PHP and direct queries. Or your first query could provide the category filtering needed by the weblog entries tag, using a limit of 1, so that only one entry would ever be shown, and a conditional in your query tag to only display an image for the category you want, if the entry is in more than one category.
My suggestion was originally going to be an extension hook, utilizing $EXT->end_script to halt the primary method’s execution, but that doesn’t seem like the best solution to your problem. The other options are more elegant, and your performance is going to be better all around, and more tailored to your specific needs here if you go the plugin route.