I figured out a really stupid workaround, assuming this is a material used in a widget.
In image settings in the widget, set “Draw As” to “Image” and “Tiling” to “Both”. “Image Size” will be locked to 32x32 - you can change the numbers in the UI, but they will not affect anything; it will still treat the size as 32x32.
Then in the material, the “9-slice UV” coordinate will be the position in a grid of 32x32 tiles. You can access DPI like so:

