If either the back of your legs (hamstrings), hips, or lower back is tight, you may have a hard time getting into this position. Many yoga poses focus on the core with a straight spine.
By practicing yoga consistently, tightness in these areas should improve, making it easier to extend the legs when sitting.
How do I train myself to sit up straight?
To more easily sit up straight, you can bend the knees or elevate your hips by sitting on a firm pillow, yoga block, or stack of books. Another option is to bring your back against a wall to gain support and body awareness for sitting up straight. Body awareness will also help as this increases your ability to ‘correct’ your posture or form.
Remember, it is always better to modify an exercise than to push through the exercise with bad form.