You can’t. A segue is something in the storyboard. Your code (programmatically) cannot see into the storyboard and change it.
Instead, you can do programmatically what the unwind segue did, such as pop back to a certain view controller.
But the general problem of "returning" to a certain view controller no matter what that may involve (some combination of dismiss and pop, etc.) is a very difficult and common one. It is certainly extremely annoying that, although a storyboard unwind
segue "knows" how to do that, there is no method that lets you do that in code. I can only suggest filing a bug report with Apple.