How to add an image dynamically to post title if it is published today or less than 2 days

I was trying to add an image like a “new” image to the posts which are just published and are less than 2 days old.

I tried using a function like this within a WP_Query but it is applying to all posts.

This is what I tried with WP_Query: