Aluminum (6061) frame dropout squeeze
It will damage the frame long term, or rather shorten the life expectancy for the rear triangle. Short term… it depends how short the term is.
Wheels are typically have standardized widths, as are frame's inner distances between the dropouts made to match them. Unless the frame is already damaged and bent or has a manufacturing defect, as the comments above suggest, you are likely trying to squeeze a 130 mm road hub wheel into a 135 mm MTB-frame (or maybe a 135 mm MTB wheel into 147 mm Boost-QR? does not matter, really)
Note that you may also have problems with adjusting the rear derailleur, as the cassette will also be off its intended position. It may not be possible to shift into the biggest rear cog.
If I were stranded somewhere far from proper components with only a 130 mm wheel to have, I would rather have attempted to add some sort of spacers taking up 2.5 + 2.5 mm at either side of the wheel, rather than compressing and stressing the dropouts.