I went down the rabbit hole a bit on this, and fair warning: my Mediawiki-fu is super-stale, as I haven't been an active editor of Wikipedia in ~6 years.
I think the magic actually lies in the subtemplates. Template:Coin maps coin names (0-8, 0*, etc.) to images named "Coin$X", where $X is the cost. Similarly, Template:P adds a potion graphic of appropriate size.
You could either modify Template:Cost and add, say, "8d" as a "coin" type next to all the pluses and stars and whatnot, then upload a graphic called "Coin8d.png", which is the super lazy way to do it. Alternately, you could make a whole new template type and bang on Template:Cost. The challenge there is the thirty different levels of nesting that template already has in terms of how it breaks out coin costs. I suspect the lazy way is the easiest until someone gets a real burning yen to do it the complex way.