Technically this is illegal, as far as I know.
You're not allowed to work in Japan without a valid visa. If they find out that you're working in Japan on a tourist visa you might not be allowed back.
It'd be a grey area (also as far as I know) to say you're freelancing/working for a Japanese company while in Japan by coincidence, and I doubt that they're very forgiving if you're sidestepping a tourist visa's restrictions.