I couldn't find any solution to use Mermaid without changing the theme to @docusaurus/theme-mermaid and trying to write a solution, and... it works great.
Create mermaid.js in /src/js/ and use it in MDX as below
(Don't forget remove .example extension from example.mdx.example)