If it is for Knowledge Articles – https://help.salesforce.com/articleView?id=sf.knowledge_create_anchors.htm&type=5.
From Custom Aura Component – https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_lightning_openSubtab.htm
Example for Aura Component – https://www.infallibletechie.com/2020/06/opensubtab-for-lightning-experience-in.html
For Flow, vote for this idea – https://trailblazer.salesforce.com/ideaView?id=0873A000000LrXrQAK. Currently, in Flows, it is not supported.