You can supersample the raster data, i.e. artificially decrease the pixel size (e.g. from 1000 m to 250 m), using a nearest neighbor resampling method and then clip the supersampled raster with your shapefile. The downside is that the size of your raster file is going to increase.
What I did when I needed to sample the spectral profile of a web map layer was to right click the layer, export the Raw Data to GeoTiff, choose an appropriate extent, and set an appropriate resolution for the layer (it likely will not set a value other than 0, which will yield a failed export).
Then, you do you work off this rendered image. Not ideal, but ...
If your only problem is the messy appearance of the "ragged edges", it might make more sense to hide the raster where it falls outside the polygon. An easy way to do this is with an inverted polygon style.
Right click on your country outline layer > duplicate.
Change the style of the duplicate layer to Inverted polygons, with a white fill and stroke style =...
Thank you @Fran Raga. I was able to solve the issue based on your reference question. For full disclosure, my working code looks like this.