While the other comments state a solution to your problem, I want to point out that having a search input inside a menu is a WCAG a11y violation and makes your application less accessible.
The items contained in a menu are child elements of the containing menu or menubar and have any of the following roles:
You can verify this yourself by running any a11y tool, like Lighthouse, to check the accessibility while the menu is open.
The Angular Material docs also mention this in their accessibility section
MatMenu should not contain any interactive controls aside from MatMenuItem.