Has Hubble ever been used to try to image a near Earth asteroid? This answer points out that the near Earth asteroid Apophis will likely be close to 2 arcseconds in diameter as seen from Earth during its close approach in 2029. I speculate that if the Hubble Space Telescope were still operational then, it could potentially image the asteroid in visible light at a few dozen pixels in diameter.

This leads me to wonder if the Hubble has ever been used to image† or at least spatially resolve in some way an asteroid during a close pass to the Earth before.

†Here the verb "image" should be taken to mean the act of producing a resolved image of an object so that different pixels correspond to intensity from different parts of the body being imaged. For the purposes of this question please don't consider telescope images in which an asteroid happens to appear but is too far away to be resolved. Thanks!
[rewritten to address the revised question]

Maybe, depending on how fussy you want to be about "resolved".

This is a study from 1995, using observations of asteroid 4179 Toutatis made in 1992 with HST. They reported marginal resolution of the asteroid, as suggested by this figure comparing a deconvolved image of a star (observed with the same filter and imager location) and a similarly deconvolved image of the asteroid itself (each pixel corresponds to about 450 m at the distance of the asteroid):



The appearance of the asteroid is pretty clearly not a point source, but it's also fair to say it's only partly resolved, and mostly just in one direction.

(My admittedly vague impression is that this is one of the best, if not the best, case of HST "resolving" a near-Earth asteroid.)

Most observations of near-Earth objects with HST are, I think, aimed at getting optical information on compositions not possible from other wavelengths, and sometimes refining estimates of rotation rates, as was done this year (using data from 2012) for the asteroid Bennu, currently being visited by OSIRIS-REx.

In practice, you get much better spatial resolution using radar (including line-of-sight distance variations due to the structure of the asteroids from time-of-return measurements, allowing you to construct 3D models of them), so there's not much point in trying to resolve them with HST.