- Make sure the image is imported as an UI sprite. You might want to slice the image in 3x3 divisions to control how it stretches.
- Set the image as a background of a panel.
- Make the score text a child of the panel
- Add a content size fitter to the panel with "preferred fit" on horizontal and/or vertical (depending on which you want to adjust automatically, set to "Unconstrained" to switch off resizing on one axis).
- Add horizontal (or vertical) layout group to the panel. It doesn't matter which one, unless you add more than one child.
It will then adapt to the size of its child.
This technique is also described in the Unity manual under "UI -> UI How Tos -> Making UI elements fit the size of their content".