The answer of @David Siegel is correct as far as it goes.
I would further venture the opinion that it is very likely that even though the Saudi Arabian embassy is not the territory of Saudi Arabia, that diplomatic immunity would very likely pose a bar to the prosecution of at least some of the defendants in a case if one was brought in Turkish courts and would make prosecution of a criminal case in the Turkish courts as a practical matter very difficult. It is possible that some of the defendants, however, would lack diplomatic immunity.
His answer does not address the further question of whether Saudi Arabia would have jurisdiction to try and criminally punish Saudi Arabian officials who committed a murder at a Saudi Arabian diplomatic complex in Turkey. The answer is that it would have jurisdiction to do so.
But, there are strong indications that the murder was committed by Saudi Arabian officials under official lawful orders from the superiors of those officials with the authority to give those orders (e.g. someone in the Crown Prince's office with whom there were at least four phone communications with the presumed murderers that day):
The Saudi entourage who went to the embassy in Turkey to cut off
journalist Jamal Khashoggi's fingers, inject him with a drug to
silence him, and dismember him with a bone saw made four calls that
day to Saudi Crown Prince Mohammed bin Salman's office, according to
Turkish media reports. The Crown Prince denies knowing anything about
the gruesome torture/murder of Khashoggi, who was a US resident. Three
of Khashoggi’s children are US citizens.
Those official orders provide provide a valid legal defense under Saudi Arabian law (to the extent that Saudi Arabia as an absolute monarchy can even be said to have rule of law in a complete and meaningful sense) to charges under Saudi Arabian jurisdiction that those officials engaged in murder.
Outside the criminal justice process, there are a variety of diplomatic and military options available to the Turkish government.
The most obvious is that it could (and likely will) expel the diplomats involved from Saudi Arabia and possibly the entire diplomatic mission from Saudi Arabia from Turkey. It could also withdraw its own diplomats from Saudi Arabia.
Turkey would also very likely be considered justified in its actions by the community of nations if it authorized the used of military force including summary assassination against the Saudi Arabian individuals it finds to have been involved, outside the criminal justice process as a political determination, although this justification would likely not extent to the Crown Prince of Saudi Arabia even if Turkey founds that he gave an order lawful under Saudi Arabian law directing the torture and murder of this individual.
The Turkish government could also probably have a basis for pushing a war crime type prosecution of at least some of the people involved.
More extremely, Turkey could declare war on Saudi Arabia generally in retaliation for this action, although this level of escalation would be considered disproportionate by most international observers standing alone.
Also, because the victim was a lawful U.S. resident, employee of a U.S. newspaper, and parent of U.S. children, it isn't inconceivable that the United States government, as well as the Turkish government, would have standing to take diplomatic or legal action against the Saudi Arabian government, although again, diplomatic immunity might bar a criminal prosecution against some of the defendants.
The issue of whether diplomatic immunity protects diplomats from prosecutions under the laws of countries other than the host country is to the best of my knowledge not a question governed by clear precedent.