If you have trouble kneeling then the exercise of kneeling can be one way of stretching your quadriceps.
To minimize the risk of injury I’d suggest learning to activate your knees and quadriceps so that you can use these actions while kneeling. Then your kneeling practice can include focusing on rhythmically activating and relaxing your knees and/or your quadriceps.
The idea of doing so is to gain control of your knees, and to induce stability while activating, and then to gradually stretch the quads while relaxing.
Leaning forwards while kneeling with hands on the floor to begin with you can practice making your knees feel strong and then relaxing them.
The advantage of this position is that it reduces stress on the knees since you can use your arms to help support some of the weight of your body.
Generally, making the knees feel strong involves activating both the quadriceps and the hamstring and focusing on the sensations at the front and the back of the knee joint.
A simple trick for activating the quadriceps while kneeling is to press your shins into the floor as if to try to lift your butt.
With your torso leaning forwards and your hands supporting you, there's less weight acting through the knee joint.
As you sit more upright your knees have to support more weight so here it may help to have blocks for your hands so that you can continue to use your hands to support your weight. Sitting more upright you can focus on activating your knees, making them feel strong, or focus on activating your quadriceps. Then relax them.
Once you are comfortable with the activation, see if you can relax your hands while activating your quadriceps, and then gradually lift them off of the blocks (or off the floor if you aren't using yoga blocks). If your knees hurt, then stop! Keep your hands on the blocks and just practice activating knees and/or quadriceps.
If you can lift your hands, then put your hands down prior to relaxing your quads. This can be a four step exercise. Activate knees and/or quadriceps, lift the hands, put the hands down (use them to support your body). Then relax the quadriceps and knees.
The next step from here, once you can comfortably hold yourself up with knee/quadriceps power is to keep your hands lifted as you gradually relax your knees and quads. You may find that you sink down as you do so and that will then be doing a kneeling quadriceps stretch.
Work towards this gradually and always have you hands on standby, or your quadriceps for that matter, so that you can halt your downwards descent when you need to.
Ideally with these techniques you can work towards a full kneeling position with your butt on the floor and then work towards deeper quadriceps stretches.
As an example, once you can get your butt to your heels and kneel comfortably the next step can be getting your butt to the floor between your feet. This can then turn into a bent back kneeling quadriceps stretch which in turn can progress to a lying quadriceps stretch.
See virasana for more on this.
But prior to that you can work on some intermediary semi-kneeling and single leg lying quadriceps stretches.