The 5G and beyond wireless systems, instead of being just an extension of 4G, are regarded as `network of networks' which is expected to integrate heterogeneous wireless networks including wireless vehicular networks (WVN). The WVN promises to solve many issues such as reducing road accidents, traffic jams, fuel consumption and commute time, which is subject to various security issues such as eavesdropping, where attackers attempt to overhear the secret transmitted signal passively (which makes the detection/defense very difficult). In this work, our objective is to implement a security scheme by improving the secrecy capacity in Sub-6 GHz and millimeter-wave (mmWave) bands. Vehicle-to-Infrastructure (V2I) for 5G and beyond wireless network. Unlike previous works where the secrecy capacity is increased by randomly augmenting the source power or setting the system combiners/precoders, in this work we employ the Gradient Ascent algorithm to search for the best combiners/precoders that maximize the secrecy rate performance. We further present two different optimization scenarios: fixed and variable transmission power.