I am building a web push WordPress plugin and I want to pass project number from form input field to manifest.json file which is included in index.php as
<link rel="manifest" href="/manifest.json">
Disclaimer: I'm the author of this plugin. Instead of building your own from scratch, you could contribute to the already existing https://github.com/mozilla/wp-web-push.
If you want to build your own, you can check the source of that plugin out to see how we have implemented it.
We've built a class to handle it: https://github.com/marco-c/wp-web-app-manifest-generator.