I can't suggest much, except to keep moving your leg a bit, whether you have it straight or bent.
Your knee makes a lubricating fluid that acts rather like oil in a rusty hinge. Moving your knee increases the amount of synovial fluid and so "oils the hinge".
Most of us find that initially we are stiff when we stand up. I used to stand still for a couple of seconds, to make sure I was properly balanced before trying to walk, and then I found that the stiffness wore off after I had taken a few steps.