I remember reading a Shia report mentioning that only 12th Imam will not pledge allegiance to the rulers which proves all the Imams before him pledged their allegiances (except Hussain).
Here, I found it:
وأما علة ما وقع من الغيبة فإن الله عزوجل يقول : « يا أيها الذين آمنوا لا تسئلوا عن أشياء إن تبد لكم تسؤكم » ( 2 ) إنه لم يكن لاحد من آبائي عليهم السلام إلا وقد وقعت في عنقه بيعة لطاغية زمانه ، وإني أخرج حين أخرج ، ولا بيعة لاحد من الطواغيت في عنقي .
And as to the cause of the transpiring of the occultation, then verily Allah (aj) says: ‘O you who believe! Do not ask about (those) things which if revealed to you would torment you’ [Surat al Ma’idah: 102].
Verily there was not one from my fathers عليهم السلام but there happened to be the bayah (pledge of allegiance) to the despot of his time on his neck, and I will emerge when I will emerge and there shall not be the bay`ah of anyone of the despots on my neck.
Source: Kamaal al Deen Wa Tamam al Ni`mah of Shaykh al Saduq, Chapter 45, Mention of the Epistles (Tauqee`aat) That Have Reached from the Qa’im ( ذكر التوقيعات الواردة عن القائم عليه السلام)
(Taken from:
https://islamistruth.wordpress.com/2010/09/18/imam-alias-allegiance-to-abu-bakrra/)
Some more reports from Shia books:
عن زرارة، عن أبي جعفر (عليه السلام) قال … كتم علي (عليه السلام) أمره وبايع مكرها حيث لم يجد أعوانا
1.) Zurarah narrated from Imam Baqir that he said : Ali had hidden his ‘amr’ and rendered allegiance with disliking when he didn’t find supporters. [Furu Kafi, 3/139]
لما وردت الكتب على اسامة انصرف بمن معه حتى دخل المدينة، فلما رأى اجتماع الخلق على ابى بكر انطلق إلى علي بن ابي طالب عليه السلام فقال له: ماهذا ؟ قال له علي: هذا ما ترى. قال له اسامة: فهل بايعته ؟ فقال: نعم يا اسامة.
2.) When the letter reached Usama, he returned with his supporters to Medinah, and when he saw that the people have united on AbuBakr, he went to Ali and asked : What is it? He replied :This is what you are observing. Usama asked : Have you also rendered allegiance to him? Ali said : Yes O Usamah! [Ihtijaj p. 50]
Shustri says:
حضرت امیر و سائر بنی ھاشم از روئے اکراہ با ابی بکر بظاھر بیعت کردند و دست بر دست اوزدند
3.) Ali and the complete bani hashim rendered allegiance to Abu Bakr with dislike, and laid their hands on his hand. [Majalis al Momineen, tadhkira Khalid ibn saeed]
فبايعت أبا بكر كما بايعتموه، وكرهت أن أشق عصا المسلمين، وأن أفرق بين جماعتهم، ثم أن أبا بكر جعلها لعمر من بعده، وأنتم تعلمون أني أولى الناس برسول الله (صلى الله عليه وآله) وبالناس من بعده، فبايعت عمر كما بايعتموه، فوفيت له ببيعته حتى لما قتل جعلني سادس ستة، فدخلت حيث أدخلني، وكرهت أن أفرق جماعة المسلمين وأشق عصاهم، فبايعتم عثمان فبايعته
4.) Ali said : I rendered allegiance to Abu Bakr just like you people rendered allegiance to him, and disliked to break the power of Muslims and disunite their jamaat, then when AbuBakr appointed Umar as Caliph after him, and you knew that I had more right after the Messenger of Allah (s), I still rendered allegiance to Umar as you rendered allegiance to him, till when he was killed and made me the member of six member council, I joined them and disliked to disunite the jamaat of the Muslims and break their power. Then you rendered allegiance to Uthman, I also rendered allegiance to him. [Amali by Tusi, 2/121]
5.) Sayyid Murtadha says in ‘al Shafi’ : What is apparent and in which there is no problem is that Ali rendered allegiance (to Abu Bakr) to protect from Sharr and escape from fitnah. [al-Shafi, p. 209]
Taken from:
https://islamistruth.wordpress.com/2012/12/27/allegiance-bayah-of-ali-to-abubakr-umar-uthman/