So firstly, by way of introduction, it is important to note the power of a name. The Gemara in Brachos 7b famously notes that a name can affect the child's future.
Interestingly, HaRav Moshe Sternbach shlita in Teshuvos Vehanhagos, Vol 2, YD #501 when asked about whether one can name after a relative who was irreligious, makes a point of mentioning the following:
ונראה שהנולד קשור למזל ומדות של הנפטר ולא קשור למעשיו
And it appears that the child is connected to the mazal (luck/destiny) and the character attributes of the departed but not connected to his actions
As such, if the dead relative had a life marred by bad occurrences, who had a bad "mazal" - naming the child with the same name forms a similar type mazal. Which in this context, would be advisable to avoid.
When digging further I came across the Sefer Chasidim 244 which says outright that a person should not name after a relative that suffered etc.:
ועוד אומר דברי' שהש' גורם לטובה או לרעה לטובה יש אדם שכל הנקראין בשמו יצליחו לגדולה זהו ויקרא בהם שמי ושם אבותי. וכתיב (ישעיהו סו כב) כי כאשר השמי' החדשי' והארץ החדשה אשר אני עושה עומדי' לפני אמר ה' כן יעמוד זרעכם ושמכם. וכתיב (ישעיהו מג א) קראתי בשמך לי אתה. הרי שיש אדם שכל אותם הנקראים על שמו יחיו ויהיו בניו קיימי' ויעמידו תולדות ויש שכל אלה להם להפך שנאמר (ישעיהו סה טו) והנחת' שמכם לשבועה לבחירי והמיתך ה' ולעבדיו יקרא שם אחר וכתיב (ישעיהו יד כב) והכרתי לבבל שם ושאר ונין ונכד וכתיב (איוב יח יט) לא נין ולא נכד בעמו ואין שריד במגוריו. וכתיב (איוב יח יז) ולא שם לו על פני חוץ. לכן יתפלל אדם שכל הנקראי' בשמו יהיו בהם מדות טובות האלה ולא אחת מן המדות הרעות ושלא יקראו זרעו על אותן שמדות הרעות תלויות בהן. כיצד יראה אדם כשיש שני אחי' וקראו שם בניהם ובנותיהם אחר שם פלוני אפילו אחר צדיק ומתו בלא תולדות. או שהיו הכתובים למעלה לרעה בהם אל יקראו יותר באותו השם ר"ל שקראו לו שם בגורל מתוך הספר כאשר עושין לחולה או בשני אחי' נתקיי' למאן דאמ' שני' לחזקה ולמאן דאמר שלשה לחזק' פעמים שהאחי' קוראי' בשם אותו האיש ונכשלים זרעו או האחים קראו את בניהם אחר אביהם ומתו והבנו' קראו בניהן וחיו ויש שם פלוני שכל המשפחה שלו אם קראו זרעם בשמם מתו בלא תולדות ולא האריכו ימיהם ובכל ענינים האלו לנקבות ובשם שירא' החכם שכך הוא אל יאמר אקיי' לאבותי שם שלא ישכח והוא רואה שנקראים אחרים ונכשלו הרי הוא נושא אל נפשו עון. ואין אלו הדברים משום ניחוש שהרי הראשונים היו קוראים את בניהם על שם המאורע ולא מתו. אא"כ חטאו בער ואונן לכך יהיו צדיקים שזרעם מתים ולא מחמת עון. אלא שאלו הדברים הזיקו ואע"פ כן יש לאדם לחשוב שמא בעונו הוא וכל שמתים בניו ואחרים קראו אחר פלוני וזה קראו כמו כן ומתו הרי נגזר עליו לפי שכינו אחרים שם כמוהו
UPDATE
I came across this link here (see Part II) which has several sources. He also addresses your question about Akiva.
It writes in Seder HaDoros that the author of the Ohr Zaruah had a dream where he questioned how Akiva should be spelt - with the final letter being an aleph or a hei. In the dream he saw the verse from Tehillim 97:11
א֭וֹר זָרֻ֣עַ לַצַּדִּ֑יק וּֽלְיִשְׁרֵי־לֵ֥ב שִׂמְחָֽה
Light is sown for the righteous, radiance for the upright.
He realised that the end letters (higlighted in bold) spelt Akiva with the last letter being a hei.
In the Shu"t Chasam Sofer, Even HaEzer 2:28 he questions how it is spelt in the Gemara (with an aleph) and how there is now a shift to using a hei. The Chasam Sofer explains there that it is due to "דריע מזליה" - "bad mazal". Therefore, even though Rebbe Akiva was a tzaddik willing to die "al kiddush Hashem", due to his tragic end we would need to make a change in the name before applying it to our children.
Rav Moshe Feinstein zt"l in Igros Moshe, YD 2:122 discusses whether one should name a child after a person who died young, and his response is that it should be "קצת קפידא", done with some reservation. He brings down the Yam Shel Shlomo on Gittin 4:31 who felt that one should strongly avoid such names, and notes that even the name Yeshayahu (Isaiah) has been changed to Yeshayah due to his tragic end (see Yevamos 49b).
(see there for further details).