There’s no public API available for restoring a ticket from Spam folder. Since there’s no platform features available around spam folders, there’s no other workaround as well.
If you would like to hear from the Freshdesk product team on the workarounds for your need, please contact Freshdesk support on support@freshdesk.com.