When the network sees a block appear with enough difficulty nodes can detect this as potentially the longest valid chain allowing the blocks miner to officially claim the block reward via coinbase transaction. Is it possible to create a Bitcoin output that is locked to the same difficulty conditions but is not a coinbase transaction? For example I could calculate the difficulty in 10 blocks and lock Bitcoin until a block with that difficulty is mined at which point the miner who wins the block will have priority to include a transaction claiming these Bitcoins.
No, there are currently no Script opcodes that access information about the difficulty. There has been discussion about a proposal called OP_DIFFICULTY in the past.
In a similar direction, I saw some people discussing an idea to create a betting market where funds would be locked up to a shared address of two Bitcoin users, Alice and Bob, with a script that can be spent in two ways: either at a given blockheight to Alice, or at a given median time passed to Bob. Depending on whether mining is faster or slower than expected, either one or the other would come to pass earlier. I can’t find the discussion at the moment, though.
Vojtěch Strnad pointed out in the comments this paper on Blockrate Binaries.