First, if your employer starts to play such silly games, you have a problem. If you're already I trouble with them anyway, the only reasonable thing to do is to consult a lawyer familiar with such matters and follow his advice.
In case you don't want to sue them and leave the company anyway, the only reasonable position is to let them have whatever they already have in hand. You can't take it from them anyway. Now to get back at them, produce some legalese statement that the code has been produced as ad-hoc tools for personal use of the creator and as a proof of concept. That those tools haven't be developed adhering to the relevant coding standards and not ready for productive use. Whatever the company does with that, they accept them as is and won't hold you liable for any thing bad happening as a result from using those tools in any way and that they will protect you from any liability claims resulting from any of your involvement with this software. Also add that this software needs to be reviewed and made ready for commercial use by qualified software engineers - which by coincidence you aren't, you're just a dumb L3 admin. If you feel nasty, add a NDA for good measure too. That won't help you, but is another hassle they'll have to resolve.
Make those statements broad enough, mention liability often enough and require a legal binding signature from the company on the contract. That will make sure that the legal department will get hold of the document and you won't have to hand over the code any time soon now. Even worse, any action in the matter on their side might be considered affecting the negotiations and review of the legal department. If they try to pressure you, write a naive question to legal asking about the progress. Bosses really hate to involve the legal department when they try to get things done.
With this, you won't get any money for the time already spent, but the company won't get the code either. You're in the comfortable position that you're cooperative and just want to handle this properly and protect you from claims. Nobody can fault you for not helping them and still, they don't get anything useful.
If they're really stupid enough to sign the document, you hand over those parts they don't have yet. Make sure you strip all useful structure, variable names and comment from it and run it afterwards through a code beautifier to make it look structured again. It's important that you don't touch files they already have, changing those would be obvious bad faith.
Now, things like those work in reality only when someone is maintaining the system. With the signed document, you as a L3 can't really be involved with that tool in any way in the future, you officially lack the skill. This has to go via software development. If the don't have any of those or can't bother them, you might want to suggest that a freelancing friend might provide the necessary skills - at slightly above the the going market rates for software consulting. I'm certain, you'll find a way of handling the doing in the future.
All in all, a company playing such silly games must be pretty stupid.