"With what [...]?" or "What [...] with?"

Yes, they are both grammatical, but With what are you doing that? is much more formal, and probably quite rare.