In vehicular-to-roadside (V2R) communications the bandwidth from roadside units (RSUs) can be shared among the vehicular users in order to improve the resource utilization and reduce the costs of bandwidth reservation. We formulate a coalitional game model to analyze the situation in which multiple vehicular users can cooperate for sharing the bandwidth from serving RSUs. First, we consider a rational coalition formation approach in which each vehicular user is self-interested, and, hence, decides to join the coalition which maximizes its individual utility. For this approach, we propose a dynamic model based on Markov chain which allows to obtain a stable coalitional structure. Further, for implementation of rational coalition formation, we propose a distributed algorithm based on well-defined merge and split mechanisms. Then, we consider the optimal coalition formation process in which the coalitions are formed so that the social welfare of all vehicular users is maximized. The performance evaluation shows that optimal coalition formation yields a higher utility than rational coalition formation due to the group-interest of all vehicular users. Also, both optimal and rational coalition formation achieve a significantly higher utility than the case without bandwidth sharing (non-cooperative case).