While it's not same with what you mentioned, it's possible if you use OP_RETURN function.
You need use BIP38 to encrypt your private and add your encrypted private key to a transaction with OP_RETURN, even though OP_RETURN function isn't supposed to store any data besides transaction/P2SH for features such as multi-sig. Also, it's risky to expose your encrypted private key, even if you encrypt it with strong passphrase.
You also need to remember the transaction ID and the process isn't user friendly.
What for though? I don't think the OP wants a method to store his encrypted private key publicly. It should never be shared online, much less a platform for which everyone can see it.
I don’t think that OP has a clear concept of what a private key is, or how the blockchain works. It sounds like he wants a way to require a password to authorize a transaction, in case the private key gets h4x0r3d. As ranochigo observes, I saw no indication of any idea to store the private key on the blockchain—just the password, which is used to authorize a spend from your Bitcoin “account”. It is one of those ideas which is “not even wrong”.
Parsing this, with curly braces added:
You { have a private key and a public key } and { optionally you could password protect your 'account' after which all transactions would require you to enter this password }. This password would obviously be stored on the blockchain itself.
Untangling the background misconceptions would require a full lesson on the basic concepts of public-key cryptography, how the blockchain works, etc. I do not think it could be done in one post, even a long one; and it would be suitable for multiple topics in
Beginners & Help (or reading some introductory books on applied cryptography and on Bitcoin—or browsing the
Bitcoin Wiki).
Is something like this possible to implement?
Short answer: No.
Also, even if such a thing were possible (which it’s not), any password you pick will be laughably insecure compared to the strength of
Bitcoin’s public-key security. That would be like propping a chair behind a bank vault door to try to prevent anybody from pushing it open. Well, it seems rather useless; and moreover, anybody who can get through the door somehow,
will be able to push aside the chair!
If your computer gets compromised (“hacked”) to the degree that your private keys are stolen, then the same attacker has the power to: Steal your password when you type it, prevent you from sending your own transaction until he has time to make a theft transaction, and/or change your send transaction details invisibly so that
you send out a transaction which sends your funds to him.
Please read up on applied cryptography and on Bitcoin concepts.
Questions here.