No, you cannot do it just like that, it takes a bit more. Please see my recent answer.
You will find short but comprehensive instructions with code samples. The installation prompt is triggered by a button on a main application, and this button is only visible when the application is not installed as PWA.