More often than not, a Martin McDonagh script sets out like the start of a joke. Two Irishmen meet in a pub, a hangman and a stranger meet in a pub, two hitmen go on holiday to Belgium, a man searches for his missing left hand, a woman purchases three billboards. McDonagh likes a well-told joke, and his films and plays are rife with them. But the scripts overall tend to swerve and sour before arriving at a punchline: His films, in particular, are frequently very funny, but they don’t tend to leave you laughing. So it proves again in “Wild Horse Nine,” starting with a joke opener practically patched together at random from other McDonagh loglines — two CIA agents go on holiday to Easter Island — and ending with a small lump in the throat.

That’s the clever, bittersweet trick of McDonagh’s writing, time and again, though in this case, much credit for the lump goes to John Malkovich. Not typically the most emotionally demonstrative of actors, he doesn’t stray far outside his dry, laconic wheelhouse in this drolly melancholic tale of two ugly Americans in a Chile on the cusp of military rule, reckoning with the fascistic influence of their presence and past, and with terminal disease besides. But as a veteran spy fucking the system as he stares death in the face, Malkovich — in his first collaboration with the writer-director — gives McDonagh’s pithy, tangy dialogue just the sad, soulful eccentricity that it needs to live off the page. Where the film, enjoyable and puckish as ever, gets just a little too neat, the actor’s hoarsely wounded, seen-it-all performance untidies things a bit.