I was told that is ok to use
in an informal setting for "I don't want anything."
Is this correct? And what is an expression I can use in a formal situation?
何でもないが欲しいです would mean 'It's nothing, but I want it.' Honestly it makes very little sense. You seem to have taken 何でもない as a noun, but really it's a full phrase meaning 'It's nothing.' To say you don't want anything, I think 何も欲しくない would work (though I'm probably wrong). It would be a little more natural to say 何も要らない 'I don't need anything', though, I think. Formally you could say 何も要らないです or 何も要りません.