Haven't gotten very far with this. Best approach so far was call a script to open:
https://$URL/index.php/Special:UserMerge?wpolduser=$user&wpnewuser=Anonymous&wpdelete=1
...where $user is the old username. Needs to be escaped, obv.
I called this through firefox, so I inherit the session cookie.
https://www.mediawiki.org/wiki/Topic:Qofnawv40jkljgzu